private IElement method_2(object object_0) { IMemoryBlobStream o = object_0 as IMemoryBlobStream; IPropertySet set = new PropertySetClass(); IObjectStream pstm = new ObjectStreamClass { Stream = o }; ESRI.ArcGIS.esriSystem.IPersistStream stream3 = set as ESRI.ArcGIS.esriSystem.IPersistStream; stream3.Load(pstm); IElement property = null; try { property = set.GetProperty("Element") as IElement; } catch (Exception) { } ComReleaser.ReleaseCOMObject(stream3); ComReleaser.ReleaseCOMObject(set); ComReleaser.ReleaseCOMObject(o); set = null; return(property); }
private IElement method_1(object object_1) { if (object_1 is DBNull) { return(null); } IMemoryBlobStream o = object_1 as IMemoryBlobStream; IPropertySet set = new PropertySetClass(); IObjectStream pstm = new ObjectStreamClass { Stream = o }; IPersistStream stream3 = set as IPersistStream; stream3.Load(pstm); IElement property = null; try { property = set.GetProperty("Element") as IElement; } catch (Exception) { } ComReleaser.ReleaseCOMObject(stream3); ComReleaser.ReleaseCOMObject(set); ComReleaser.ReleaseCOMObject(o); set = null; return(property); }
private string method_0(object object_0) { if (object_0 is DBNull) { return(""); } IMemoryBlobStream o = object_0 as IMemoryBlobStream; IPropertySet set = new PropertySetClass(); IObjectStream pstm = new ObjectStreamClass { Stream = o }; IPersistStream stream3 = set as IPersistStream; stream3.Load(pstm); string str2 = ""; try { str2 = set.GetProperty("TK").ToString(); } catch (Exception) { } ComReleaser.ReleaseCOMObject(stream3); ComReleaser.ReleaseCOMObject(set); ComReleaser.ReleaseCOMObject(o); set = null; return(str2); }
/// <summary> /// Initializes a new instance of the <see cref="ComSerializable{T}" /> class. /// </summary> /// <param name="info">The information.</param> /// <param name="context">The context.</param> protected ComSerializable(SerializationInfo info, StreamingContext context) { byte[] data = (byte[])info.GetValue("DATA", typeof(byte[])); string progId = info.GetString("PROGID"); using (ComReleaser com = new ComReleaser()) { IMemoryBlobStream blob = new MemoryBlobStreamClass(); com.ManageLifetime(blob); IMemoryBlobStreamVariant variant = (IMemoryBlobStreamVariant)blob; variant.ImportFromVariant(data); IObjectStream stream = new ObjectStreamClass(); stream.Stream = blob; com.ManageLifetime(stream); Type t = Type.GetTypeFromProgID(progId); IPersistStream persist = (IPersistStream)Activator.CreateInstance(t); persist.Load(stream); this.Value = (T)persist; } }
/// <summary> /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with the data needed to serialize the /// target object. /// </summary> /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> to populate with data.</param> /// <param name="context"> /// The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext" />) for this /// serialization. /// </param> public void GetObjectData(SerializationInfo info, StreamingContext context) { using (ComReleaser cr = new ComReleaser()) { IPersistStream persist = this.Value as IPersistStream; if (persist == null) { return; } IObjectStream stream = new ObjectStreamClass(); cr.ManageLifetime(stream); IMemoryBlobStream blob = new MemoryBlobStreamClass(); cr.ManageLifetime(blob); stream.Stream = blob; persist.Save(stream, 0); IMemoryBlobStreamVariant variant = (IMemoryBlobStreamVariant)blob; object value; variant.ExportToVariant(out value); var data = (byte[])value; info.AddValue("DATA", data); info.AddValue("PROGID", this.ProgId); } }
public static EsriDataObject ConvertToEsriDataObject(IDataObject dataObject) { // EsriDataObject esriDataObject = new EsriDataObject(); // Exit if dropped object is invalid if (EsriDataObject.IsValid(dataObject)) { // Get Byte Array from DataObject object esriLayers = dataObject.GetData(EsriRegistry.DATAOBJECT_ESRILAYERS); MemoryStream memoryStream = (MemoryStream)esriLayers; byte[] bytes = memoryStream.ToArray(); // Load Byte Array into a Stream (ESRI Wrapper of IStream) IMemoryBlobStreamVariant memoryBlobStreamVariant = new MemoryBlobStreamClass(); memoryBlobStreamVariant.ImportFromVariant(bytes); IMemoryBlobStream2 memoryBlobStream = (IMemoryBlobStream2)memoryBlobStreamVariant; IStream stream = (IStream)memoryBlobStream; // Load Stream into an ESRI ObjectStream IObjectStream objectStream = new ObjectStreamClass(); objectStream.Stream = stream; // Get Number of Layers in Dropped Object byte pv; uint cb = sizeof(int); uint pcbRead; objectStream.RemoteRead(out pv, cb, out pcbRead); int count = Convert.ToInt32(pv); // Define Guids Guid guidLayer = new Guid(EsriRegistry.INTERFACE_ILAYER); Guid guidTable = new Guid(EsriRegistry.INTERFACE_ITABLEPROPERTY); // Get Dropped Layers for (int i = 0; i < count; i++) { object o = objectStream.LoadObject(ref guidLayer, null); ILayer layer = (ILayer)o; esriDataObject.LayerCollection.Add(layer); } // Get Dropped TableProperties for (int i = 0; i < count; i++) { object o = objectStream.LoadObject(ref guidTable, null); if (o == null) { continue; } ITableProperty tableProperty = (ITableProperty)o; esriDataObject.TablePropertyCollection.Add(tableProperty); } } return(esriDataObject); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void writeClassDescriptor(java.io.ObjectStreamClass desc) throws java.io.IOException protected internal override void WriteClassDescriptor(ObjectStreamClass desc) { if (_versionMapper.hasMappingFor(desc.Name)) { UpdateWirePayloadSuid(desc); } base.WriteClassDescriptor(desc); }
private object method_2(IPropertySet pPropertySet) { IMemoryBlobStream stream = new MemoryBlobStreamClass(); IObjectStream pstm = new ObjectStreamClass { Stream = stream }; (pPropertySet as IPersistStream).Save(pstm, 0); return(stream); }
private void SaveBookmarkDatFile(string filePath, ISceneBookmarks _SceneBookmarks) { try { IObjectStream pObjStream = new ObjectStreamClass(); _SceneBookmarks.SaveBookmarks(pObjStream.Stream); IMemoryBlobStream pMemBlobStream = pObjStream.Stream as IMemoryBlobStream; pMemBlobStream.SaveToFile(filePath); } catch { } }
private void LoadBookmarkDatFile(string filePath, ISceneBookmarks _SceneBookmarks) { try { IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass(); pMemoryBlobStream.LoadFromFile(filePath); IObjectStream pObjectStream = new ObjectStreamClass(); pObjectStream.Stream = pMemoryBlobStream as IStream; _SceneBookmarks.LoadBookmarks(pObjectStream.Stream); } catch { } }
private void UpdateWirePayloadSuid(ObjectStreamClass wirePayload) { try { System.Reflection.FieldInfo field = GetAccessibleSuidField(wirePayload); field.set(wirePayload, _versionMapper.mappingFor(wirePayload.Name)); } catch (Exception e) when(e is NoSuchFieldException || e is IllegalAccessException) { throw new Exception(e); } }
/// <exception cref="System.IO.IOException"></exception> /// <exception cref="System.TypeLoadException"></exception> protected override Type ResolveClass(ObjectStreamClass desc) { string name = desc.GetName(); if (classLoader != null) { try { return classLoader.LoadClass(name); } catch (TypeLoadException) { } } // fall through to default loading return base.ResolveClass(desc); }
private IPropertySet method_3(object object_1) { if (object_1 is DBNull) { return(null); } IMemoryBlobStream o = object_1 as IMemoryBlobStream; IPropertySet set2 = new PropertySetClass(); IObjectStream pstm = new ObjectStreamClass { Stream = o }; (set2 as IPersistStream).Load(pstm); ComReleaser.ReleaseCOMObject(o); return(set2); }
public static void SetBlobValue(this IActiveRecord wrapper, FieldAttribute attribute, object value) { if (!(value is IPersistStream)) { throw new ActiveRecordException("Nâo é possível persistir um objeto que não implementa IPersistStream."); } IMemoryBlobStream memStream = new MemoryBlobStreamClass(); IObjectStream objStream = new ObjectStreamClass(); objStream.Stream = memStream; IPersistStream persist = (IPersistStream)value; persist.Save(memStream, 0); wrapper.UnderlyingObject.set_Value(attribute.Index, memStream); }
private IFeatureRenderer ReadRender(string filename) { System.IO.FileStream input = new System.IO.FileStream(filename, FileMode.Open); BinaryReader reader = new BinaryReader(input); int count = reader.ReadInt32(); byte[] buffer = reader.ReadBytes(count); IMemoryBlobStream stream2 = new MemoryBlobStreamClass(); IObjectStream pstm = new ObjectStreamClass { Stream = stream2 }; ((IMemoryBlobStreamVariant)stream2).ImportFromVariant(buffer); IPropertySet set = new PropertySetClass(); (set as IPersistStream).Load(pstm); return(set.GetProperty("Render") as IFeatureRenderer); }
public static object GetBlobValue(this IActiveRecord wrapper, FieldAttribute attribute) { IMemoryBlobStream blobStream = wrapper.UnderlyingObject.get_Value(attribute.Index) as IMemoryBlobStream; if (blobStream == null) { return(null); } IObjectStream stream = new ObjectStreamClass() { Stream = blobStream }; IPersistStream blob = new PropertySetClass(); blob.Load(blobStream); return(blob as IPropertySet); }
private string method_6(ISymbol isymbol_0) { Guid guid; object obj2; ESRI.ArcGIS.esriSystem.IPersistStream stream = (ESRI.ArcGIS.esriSystem.IPersistStream)isymbol_0; IMemoryBlobStream pstm = new MemoryBlobStreamClass(); IObjectStream stream3 = new ObjectStreamClass { Stream = pstm }; stream.GetClassID(out guid); stream.Save(pstm, 1); ((IMemoryBlobStreamVariant)pstm).ExportToVariant(out obj2); System.Array array = obj2 as Array; byte[] buffer = new byte[array.Length + 16]; guid.ToByteArray().CopyTo(buffer, 0); array.CopyTo(buffer, 16); return(Convert.ToBase64String(buffer)); }
private object CloneElement(IElement pElement) { IClone clone = pElement as IClone; IMemoryBlobStream stream = new MemoryBlobStreamClass(); IObjectStream pstm = new ObjectStreamClass { Stream = stream }; IPropertySet set = new PropertySetClass(); IPersistStream stream3 = set as IPersistStream; try { set.SetProperty("Element", clone.Clone()); stream3.Save(pstm, 0); } catch { } return(stream); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add CmdOpenSceneDoc.OnClick implementation //文件名称 string pOpenFileName = ""; OpenFileDialog pOpenDoc = new OpenFileDialog(); pOpenDoc.Title = "打开三维空间"; pOpenDoc.Filter = "ArcScene Document(*.sxd)|*.sxd"; if (pOpenDoc.ShowDialog() == DialogResult.OK) { pOpenFileName = pOpenDoc.FileName; } try { if (pSceneControl.CheckSxFile(pOpenFileName)) { pSceneControl.LoadSxFile(pOpenFileName); } else { IScene pScene = pSceneControl.Scene; IObjectStream pObjectStream = new ObjectStreamClass(); IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass(); pMemoryBlobStream.LoadFromFile(pOpenFileName); pObjectStream.Stream = pMemoryBlobStream; IPersistStream pPersistStream = pScene as IPersistStream; pPersistStream.Load(pObjectStream); } } catch { //MessageBox.Show("文件选择为空或者选择格式不正确!"); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add CmdSaveSceneDoc.OnClick implementation for (int i = 0; i < pSceneControl.Scene.LayerCount; i++) { ILayer pLayer = pSceneControl.Scene.get_Layer(i); if (pLayer == pSceneControl.Scene.ActiveGraphicsLayer) { pSceneControl.Scene.DeleteLayer(pLayer); pSceneControl.Scene.SceneGraph.RefreshViewers(); } } try { //文件名称 string pSaveFileName = ""; SaveFileDialog pSaveDoc = new SaveFileDialog(); pSaveDoc.Title = "保存工作空间"; pSaveDoc.Filter = "ArcScene Document(*.sxd)|*.sxd"; if (pSaveDoc.ShowDialog() == DialogResult.OK) { pSaveFileName = pSaveDoc.FileName; } IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass(); IObjectStream pObjectStream = new ObjectStreamClass(); pObjectStream.Stream = pMemoryBlobStream; IPersistStream pPersistStream = pSceneControl.Scene as IPersistStream; pPersistStream.Save(pObjectStream, 1); pMemoryBlobStream.SaveToFile(pSaveFileName); } catch { } }
private void SaveRender(IFeatureRenderer pRender, string filename) { object obj2; IMemoryBlobStream stream = new MemoryBlobStreamClass(); IObjectStream pstm = new ObjectStreamClass { Stream = stream }; IPropertySet set = new PropertySetClass(); IPersistStream stream3 = set as IPersistStream; set.SetProperty("Render", pRender); stream3.Save(pstm, 0); ((IMemoryBlobStreamVariant)stream).ExportToVariant(out obj2); System.IO.FileStream output = new System.IO.FileStream(filename, FileMode.CreateNew); BinaryWriter writer = new BinaryWriter(output); writer.Write(((byte[])obj2).Length); writer.Write((byte[])obj2); writer.Close(); output.Close(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected java.io.ObjectStreamClass readClassDescriptor() throws java.io.IOException, ClassNotFoundException protected internal override ObjectStreamClass ReadClassDescriptor() { ObjectStreamClass wireClassDescriptor = base.ReadClassDescriptor(); if (!_versionMapper.hasMappingFor(wireClassDescriptor.Name)) { _versionMapper.addMappingFor(wireClassDescriptor.Name, wireClassDescriptor.SerialVersionUID); } Type localClass; // the class in the local JVM that this descriptor represents. try { localClass = Type.GetType(wireClassDescriptor.Name); } catch (ClassNotFoundException) { return(wireClassDescriptor); } ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass); if (localClassDescriptor != null) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long localSUID = localClassDescriptor.getSerialVersionUID(); long localSUID = localClassDescriptor.SerialVersionUID; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long wireSUID = wireClassDescriptor.getSerialVersionUID(); long wireSUID = wireClassDescriptor.SerialVersionUID; if (wireSUID != localSUID) { wireClassDescriptor = localClassDescriptor; } } return(wireClassDescriptor); }
protected virtual void writeClassDescriptor(ObjectStreamClass prm1) { }
protected virtual global::java.lang.Class <global::System.Object> resolveClass(ObjectStreamClass prm1) { return(default(global::java.lang.Class <global::System.Object>)); }
/// <summary> /// Use the given ClassLoader rather than using the system class /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("rawtypes") protected Class resolveClass(java.io.ObjectStreamClass classDesc) throws java.io.IOException, ClassNotFoundException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: protected internal override Class ResolveClass(ObjectStreamClass classDesc) { String cname = classDesc.Name; return(ClassFinder.resolveClass(cname, this.Loader)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected Class resolveClass(java.io.ObjectStreamClass desc) throws java.io.IOException, ClassNotFoundException protected internal virtual Type resolveClass(ObjectStreamClass desc) { return(ReflectUtil.loadClass(desc.Name)); }
public SerialCallbackContext(global::System.Object prm1, ObjectStreamClass prm2) { }
private long SerialVersionUIDFor(MemberIsAvailable memberIsAvailable) { return(ObjectStreamClass.lookup(memberIsAvailable.GetType()).SerialVersionUID); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private Field getAccessibleSuidField(java.io.ObjectStreamClass localClassDescriptor) throws NoSuchFieldException private System.Reflection.FieldInfo GetAccessibleSuidField(ObjectStreamClass localClassDescriptor) { System.Reflection.FieldInfo suidField = localClassDescriptor.GetType().getDeclaredField("suid"); suidField.Accessible = true; return(suidField); }
/// <exception cref="System.IO.IOException"></exception> /// <exception cref="System.TypeLoadException"></exception> protected override Type ResolveClass(ObjectStreamClass streamClass) { Type c = Sharpen.Runtime.GetType(streamClass.GetName(), false, loader); if (c == null) { return base.ResolveClass(streamClass); } else { return c; } }
public static object GetBlobValue(this IActiveRecord wrapper, FieldAttribute attribute) { IMemoryBlobStream blobStream = wrapper.UnderlyingObject.get_Value(attribute.Index) as IMemoryBlobStream; if (blobStream == null) return null; IObjectStream stream = new ObjectStreamClass() { Stream = blobStream }; IPersistStream blob = new PropertySetClass(); blob.Load(blobStream); return blob as IPropertySet; }
public static void SetBlobValue(this IActiveRecord wrapper, FieldAttribute attribute, object value) { if (!(value is IPersistStream)) throw new ActiveRecordException("Nâo é possível persistir um objeto que não implementa IPersistStream."); IMemoryBlobStream memStream = new MemoryBlobStreamClass(); IObjectStream objStream = new ObjectStreamClass(); objStream.Stream = memStream; IPersistStream persist = (IPersistStream)value; persist.Save(memStream, 0); wrapper.UnderlyingObject.set_Value(attribute.Index, memStream); }