示例#1
0
 public static BinTreePropertyViewModel ConstructTreePropertyViewModel(BinTreeParentViewModel parent, BinTreeProperty genericProperty)
 {
     return(genericProperty switch
     {
         BinTreeNone property => new BinTreePropertyViewModel(parent, property),
         BinTreeBool property => new BinTreeBoolViewModel(parent, property),
         BinTreeSByte property => new BinTreeSByteViewModel(parent, property),
         BinTreeByte property => new BinTreeByteViewModel(parent, property),
         BinTreeInt16 property => new BinTreeInt16ViewModel(parent, property),
         BinTreeUInt16 property => new BinTreeUInt16ViewModel(parent, property),
         BinTreeInt32 property => new BinTreeInt32ViewModel(parent, property),
         BinTreeUInt32 property => new BinTreeUInt32ViewModel(parent, property),
         BinTreeInt64 property => new BinTreeInt64ViewModel(parent, property),
         BinTreeUInt64 property => new BinTreeUInt64ViewModel(parent, property),
         BinTreeFloat property => new BinTreeFloatViewModel(parent, property),
         BinTreeVector2 property => new BinTreeVector2ViewModel(parent, property),
         BinTreeVector3 property => new BinTreeVector3ViewModel(parent, property),
         BinTreeVector4 property => new BinTreeVector4ViewModel(parent, property),
         BinTreeMatrix44 property => new BinTreeMatrix44ViewModel(parent, property),
         BinTreeColor property => new BinTreeColorViewModel(parent, property),
         BinTreeHash property => new BinTreeHashViewModel(parent, property),
         BinTreeWadEntryLink property => new BinTreeWadEntryLinkViewModel(parent, property),
         BinTreeUnorderedContainer property => new BinTreeUnorderedContainerViewModel(parent, property),
         BinTreeContainer property => new BinTreeContainerViewModel(parent, property),
         BinTreeString property => new BinTreeStringViewModel(parent, property),
         BinTreeEmbedded property => new BinTreeEmbeddedViewModel(parent, property),
         BinTreeStructure property => new BinTreeStructureViewModel(parent, property),
         BinTreeObjectLink property => new BinTreeObjectLinkViewModel(parent, property),
         BinTreeOptional property => new BinTreeOptionalViewModel(parent, property),
         BinTreeMap property => new BinTreeMapViewModel(parent, property),
         BinTreeBitBool property => new BinTreeBitBoolViewModel(parent, property),
         _ => null,
     });
示例#2
0
        public PropertyTemplate(BinTreePropertyViewModel viewModel)
        {
            this.Name = viewModel.Name;
            this.Type = viewModel.TreeProperty.Type;

            if (viewModel is BinTreeContainerViewModel containerViewModel)
            {
                this.PrimaryType = (containerViewModel.TreeProperty as BinTreeContainer).PropertiesType;
            }
            else if (viewModel is BinTreeUnorderedContainerViewModel unorderedContainerViewModel)
            {
                this.PrimaryType = (unorderedContainerViewModel.TreeProperty as BinTreeContainer).PropertiesType;
            }
            else if (viewModel is BinTreeMapViewModel mapViewModel)
            {
                BinTreeMap map = mapViewModel.TreeProperty as BinTreeMap;

                this.PrimaryType   = map.KeyType;
                this.SecondaryType = map.ValueType;
            }
            else if (viewModel is BinTreeOptionalViewModel optionalViewModel)
            {
                BinTreeOptional optional = optionalViewModel.TreeProperty as BinTreeOptional;

                this.PrimaryType = optional.ValueType;
            }
            else if (viewModel is BinTreeStructureViewModel structureViewModel)
            {
                this.MetaClass = structureViewModel.MetaClass;
            }
            else if (viewModel is BinTreeEmbeddedViewModel embeddedViewModel)
            {
                this.MetaClass = embeddedViewModel.MetaClass;
            }
        }
示例#3
0
 private static IEnumerable <string> ProcessBinTreeProperty(BinTreeProperty treeProperty)
 {
     return(treeProperty switch
     {
         BinTreeString property => ProcessBinTreeString(property),
         BinTreeOptional property => ProcessBinTreeOptional(property),
         BinTreeContainer property => ProcessBinTreeContainer(property),
         BinTreeStructure property => ProcessBinTreeStructure(property),
         BinTreeMap property => ProcessBinTreeMap(property),
         _ => Enumerable.Empty <string>()
     });
示例#4
0
        private static object DeserializeOptional(MetaEnvironment environment, Type propertyType, BinTreeOptional optional)
        {
            bool   isSome         = optional.Value is not null;
            object value          = isSome ? DeserializeTreeProperty(environment, optional.Value) : GetTypeDefault(propertyType);
            object optionalObject = Activator.CreateInstance(propertyType, new[] { value, isSome });

            return(optionalObject);
        }