SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MyObject someInstance = new MyObject(new MyObjectConfig(){
  2.    .
  3.    .
  4. });
  5.    
  6. MyObject someInstance = MyObject.Create(
  7.      new MyObjectConfig(){
  8.        level = 5,
  9.        name = "Gorlock",
  10.        age = 15,
  11.        map = owningMap
  12.      }
  13. );
  14.    
  15. MyObject someInstance = MyObject.Create(
  16.      new MyObjectConfig(){      
  17.        name = "Gorlock"              
  18.      }
  19. );
  20.    
  21. class ConfigMyObject
  22. {
  23.    public int Level {get;set;}
  24.    public string Name {get;set;}
  25.    ...
  26.    public Map Location {get;set;}=defaultLocation;//автосвойство в котором сразу задаем свойство по умолчанию равное начальной карте или карте по умолчанию!
  27. }
  28.    
  29. class MyObject
  30. {
  31.       public MyObject(int Lev,string Name ... Map Loc)
  32.          {
  33.            level =Lev;
  34.            name =Name;
  35.            ...
  36.           location=loc;
  37.          }
  38.    public static MyObject Create(ConfigMyObject Config)
  39.     {
  40.        return new MyObject(Config.Level,Config.Name, ... Config.Location);
  41.     }
  42.  
  43. }
  44.    
  45. MyObject someInstance = MyObject.Create(
  46.  new MyObjectConfig(){      
  47.    Name = "Gorlock"              
  48.  }
  49.  );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top