public void SetStoreBoxContainer(TModelClass Instance, StoreBox <TValue> Container) { if (Container != null && Instance is TModelClass) { this.StoreBoxSetter(Instance, Container); } }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Static Constructor. /// </summary> static FileDataType() { StoreBox.RegisterStorableType <FileDataType>(filetypecode => PredefinedFileTypes.FirstOrDefault(predef => predef.TechName == filetypecode.BytesToString()).NullDefault(FileTypeAny), filetype => filetype.TechName.AbsentDefault(FileTypeAny.TechName).StringToBytes()); FileTypeImage.FilterForSave = Display.IMAGE_FILE_WRITE_EXTENSIONS.Split(';').GetConcatenation(ext => ext.ToUpper() + " format.|*." + ext, "|"); }
/// <summary> /// Sets the Symbol-Format Property/Text-Format Value for the specified Instance and Key. /// </summary> public static void SetValue(VisualElement Instance, string PropertyKey, object Value) { object GlobalValue = null; bool ValuesAreDifferent = false; MModelPropertyDefinitor PropDef = null; var StorageKey = PropertyKey; if (PropertyKey.StartsWith(TEXTFORMAT_PREFIX)) { var TxtFormat = Instance.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.DefaultSymbolFormat .GetTextFormat((ETextPurpose)Enum.Parse(typeof(ETextPurpose), PropertyKey.Substring(1))); GlobalValue = TxtFormat; ValuesAreDifferent = !TxtFormat.IsEquivalentTo((TextFormat)Value); } else { VisualElementFormat DefaultFormat = null; if (Instance is VisualSymbol) { PropDef = VisualSymbolFormat.__ClassDefinitor.GetPropertyDef(PropertyKey); DefaultFormat = Instance.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.DefaultSymbolFormat; } else { PropDef = VisualConnectorsFormat.__ClassDefinitor.GetPropertyDef(PropertyKey); DefaultFormat = ((RelationshipVisualRepresentation)Instance.OwnerRepresentation).RepresentedRelationship .RelationshipDefinitor.Value.DefaultConnectorsFormat; } GlobalValue = PropDef.Read(DefaultFormat); ValuesAreDifferent = (GlobalValue != Value); } // Do not do this concatenation for Visual-Symbol to not loose users' (stock) already stored formatting. if (Instance is VisualConnector) { StorageKey = VisualConnector.__ClassDefinitor.TechName + "." + PropertyKey; // Avoids ambiguity between VisualElementFormat descendants } if (ValuesAreDifferent) { if (Value != null && PropDef != null && PropDef.IsStoreBoxBased) { Value = StoreBox.CreateStoreBoxForType(PropDef.DataType, Value); } Instance.OwnerRepresentation.CustomFormatValues.AddOrReplace(StorageKey, Value); } else { Instance.OwnerRepresentation.CustomFormatValues.Remove(StorageKey); } }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Initializes the instance for use after creation or deserialization. /// </summary> public void Initialize() { StoreBox.RegisterSharedReferencesCentralizer(this.GlobalId, this.CentralizedStoreBoxSharedReferences); if (this.RootView != null) { this.RootView.Initialize(); } this.IdentificationScopeController = new IdentificationController(General.IsValidIdentifier, General.IsValidText, txt => General.TextToIdentifier(txt, true), idn => General.IdentifierToText(idn)); }
/// <summary> /// Static Constructor. /// </summary> static LinkDataType() { StoreBox.RegisterStorableType <LinkDataType>(block => { if (block == null || block.Length < 1) { return(null); } if (block[0] == LINKTYPECODE_GENERIC) { return(GenericLink); } if (block[0] == LINKTYPECODE_INTERNAL) { return(InternalLinkType.InternalTypeAny); } return(ResourceLinkType.PredefinedResourceTypes .FirstOrDefault(predef => predef.TechName == block.ExtractSegment(1).BytesToString()) .NullDefault(ResourceLinkType.ResourceTypeAny)); }, linkt => { if (linkt == null) { return(null); } if (linkt is InternalLinkType) { return(LINKTYPECODE_INTERNAL.IntoArray()); } if (linkt.GetType() == typeof(LinkDataType)) { return(LINKTYPECODE_GENERIC.IntoArray()); } return(BytesHandling.FusionateByteArrays(LINKTYPECODE_RESOURCE.IntoArray(), ((ResourceLinkType)linkt).TechName.AbsentDefault(ResourceLinkType.ResourceTypeAny.TechName).StringToBytes())); }); }