public ExplorerObjectSerialization(IExplorerObject exObject) { if (!PlugInManager.IsPlugin(exObject)) { return; } _guid = PlugInManager.PlugInID(exObject); _fullname = exObject.FullName; }
public void Save(IPersistStream stream) { foreach (IGraphicElement grElement in _elements) { if (PlugInManager.IsPlugin(grElement) && grElement is IPersistable) { stream.Save("GraphicElement", grElement); } } }
private void MakeGUI() { cmbSymbolTypes.Items.Clear(); if (PlugInManager.IsPlugin(_symbol)) { PlugInManager compManager = new PlugInManager(); foreach (var symbolType in compManager.GetPlugins(Plugins.Type.ISymbol)) { ISymbol symbol = compManager.CreateInstance <ISymbol>(symbolType); if (symbol is SymbolCollection) { continue; } if (_symbol.GetType().Equals(symbol.GetType())) { symbol = _symbol; } if (_symbol is IPointSymbol && symbol is IPointSymbol) { cmbSymbolTypes.Items.Add(new SymbolItem(symbol)); } if (_symbol is ILineSymbol && symbol is ILineSymbol) { cmbSymbolTypes.Items.Add(new SymbolItem(symbol)); } if (_symbol is IFillSymbol && symbol is IFillSymbol) { cmbSymbolTypes.Items.Add(new SymbolItem(symbol)); } if (_symbol is ITextSymbol && symbol is ITextSymbol) { ((ITextSymbol)symbol).Text = "Label"; cmbSymbolTypes.Items.Add(new SymbolItem(symbol)); } if (_symbol.GetType().Equals(symbol.GetType()) && cmbSymbolTypes.Items.Count > 0) { cmbSymbolTypes.SelectedItem = cmbSymbolTypes.Items[cmbSymbolTypes.Items.Count - 1]; } } } }
public void AddSymbol(ISymbol symbol, bool visible) { if (!PlugInManager.IsPlugin(symbol)) { return; } if (symbol is SymbolCollection) { foreach (SymbolCollectionItem item in ((SymbolCollection)symbol).Symbols) { _symbols.Add(item); } } else { _symbols.Add(new SymbolCollectionItem(symbol, visible)); } }
public ExtensionSerializer(object extension) { if (PlugInManager.IsPlugin(extension) && extension is IPersistable) { XmlStream stream = new XmlStream(""); ((IPersistable)extension).Save(stream); MemoryStream ms = new MemoryStream(); stream.WriteStream(ms); ms.Position = 0; byte[] b = new byte[ms.Length]; ms.Read(b, 0, (int)ms.Length); _string = System.Text.Encoding.Unicode.GetString(b).Trim(); _guid = PlugInManager.PlugInID(extension); } }
private void btnAdd_Click(object sender, System.EventArgs e) { if (_selectedSymbol == null) { return; } if (PlugInManager.IsPlugin(_selectedSymbol)) { PlugInManager comMan = new PlugInManager(); ISymbol newSymbol = (ISymbol)comMan.CreateInstance(PlugInManager.PlugInID(_selectedSymbol)); if (newSymbol != null) { AddSymbol(newSymbol); } if (SelectedSymbolChanged != null) { SelectedSymbolChanged(_selectedSymbol); } } }
private void Save(string key, object val, bool encrypt) { XmlNode node = this.CreateNode(key); _parent.Node.AppendChild(node); if (PlugInManager.IsPlugin(val)) { node.Attributes.Append( this.CreateAttribute("GUID", PlugInManager.PlugInID(val).ToString())); node.Attributes.Append( this.CreateAttribute("type", val.ToString())); } if (val is IPersistable) { _parent.Node = node; ((IPersistable)val).Save(this); _parent.Node = node.ParentNode; return; } if (val is IPersistableLoadAsync) { _parent.Node = node; ((IPersistableLoadAsync)val).Save(this); _parent.Node = node.ParentNode; return; } if (val is XmlStreamObject) { if (((XmlStreamObject)val).Value == null) { return; } CreateXmlStreamObjectAttributes(node, (XmlStreamObject)val); if (val is XmlStreamOption && ((XmlStreamOption)val).Options != null) { XmlStreamOption streamObject = (XmlStreamOption)val; node.Attributes.Append( this.CreateAttribute("type", typeof(XmlStreamOption).ToString())); _parent.Node = node; Save("Value", streamObject.Value); foreach (object option in streamObject.Options) { Save("Option", option); } _parent.Node = node.ParentNode; } else if (val is XmlStreamStringArray && ((XmlStreamStringArray)val).Value is Array) { XmlStreamStringArray streamObject = (XmlStreamStringArray)val; node.Attributes.Append( this.CreateAttribute("type", typeof(XmlStreamStringArray).ToString())); _parent.Node = node; foreach (object Value in (Array)streamObject.Value) { Save("Value", Value.ToString()); } _parent.Node = node.ParentNode; } else { XmlStreamObject streamObject = (XmlStreamObject)val; node.Attributes.Append( this.CreateAttribute("type", typeof(XmlStreamObject).ToString())); _parent.Node = node; Save("Value", streamObject.Value); _parent.Node = node.ParentNode; } return; } if (val != null) { if (node.Attributes["type"] == null) { node.Attributes.Append( this.CreateAttribute("type", val.GetType().ToString())); } if (val.GetType() == typeof(double)) { node.Attributes.Append( this.CreateAttribute("value", ((double)val).ToString(_parent.NumberFormat))); } else if (val.GetType() == typeof(float)) { node.Attributes.Append( this.CreateAttribute("value", ((float)val).ToString(_parent.NumberFormat))); } else if (val.GetType() == typeof(decimal)) { node.Attributes.Append( this.CreateAttribute("value", ((decimal)val).ToString(_parent.NumberFormat))); } else { string v = val.ToString(); if (encrypt == true) { v = Crypto.Encrypt(v, "3f9932916f9746e1a3df048cc70dd30a"); node.Attributes.Append(this.CreateAttribute("encryption_type", "1")); } node.Attributes.Append( this.CreateAttribute("value", v)); } } //object f=Activator.CreateInstance(System.Type.GetType("System.String",false,true)); //f=null; }