Esempio n. 1
0
 internal State(MemoryStream ms, int storageType, AxHost ctl, PropertyBagStream propBag)
 {
     type = storageType;
     PropertyBagBinary = propBag;
     // dangerous?
     length       = (int)ms.Length;
     this.ms      = ms;
     manualUpdate = ctl.GetAxState(AxHost.manualUpdate);
     licenseKey   = ctl.GetLicenseKey();
 }
Esempio n. 2
0
 internal State(MemoryStream memoryStream, int storageType, AxHost control, PropertyBagStream propertyBag)
 {
     Type         = storageType;
     _propertyBag = propertyBag;
     // dangerous?
     _length       = (int)memoryStream.Length;
     _memoryStream = memoryStream;
     _manualUpdate = control.GetAxState(s_manualUpdate);
     _licenseKey   = control.GetLicenseKey();
 }
Esempio n. 3
0
            protected State(SerializationInfo info, StreamingContext context)
            {
                SerializationInfoEnumerator sie = info.GetEnumerator();

                if (sie is null)
                {
                    return;
                }

                for (; sie.MoveNext();)
                {
                    if (string.Compare(sie.Name, "Data", true, CultureInfo.InvariantCulture) == 0)
                    {
                        try
                        {
                            byte[] dat = (byte[])sie.Value;
                            if (dat is not null)
                            {
                                using var datMemoryStream = new MemoryStream(dat);
                                InitializeFromStream(datMemoryStream);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.Fail("failure: " + e.ToString());
                        }
                    }
                    else if (string.Compare(sie.Name, nameof(PropertyBagBinary), true, CultureInfo.InvariantCulture) == 0)
                    {
                        try
                        {
                            Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "Loading up property bag from stream...");
                            byte[] dat = (byte[])sie.Value;
                            if (dat is not null)
                            {
                                PropertyBagBinary         = new PropertyBagStream();
                                using var datMemoryStream = new MemoryStream(dat);
                                PropertyBagBinary.Read(datMemoryStream);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.Fail("failure: " + e.ToString());
                        }
                    }
                }
            }
Esempio n. 4
0
            protected State(SerializationInfo info, StreamingContext context)
            {
                SerializationInfoEnumerator enumerator = info.GetEnumerator();

                if (enumerator is null)
                {
                    return;
                }

                for (; enumerator.MoveNext();)
                {
                    if (string.Equals(enumerator.Name, DataSerializationName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        try
                        {
                            byte[] data = (byte[])enumerator.Value;
                            if (data is not null)
                            {
                                using var datMemoryStream = new MemoryStream(data);
                                InitializeFromStream(datMemoryStream);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.Fail($"failure: {e}");
                        }
                    }
                    else if (string.Equals(enumerator.Name, PropertyBagSerializationName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        try
                        {
                            Debug.WriteLineIf(s_axHTraceSwitch.TraceVerbose, "Loading up property bag from stream...");
                            byte[] data = (byte[])enumerator.Value;
                            if (data is not null)
                            {
                                _propertyBag = new PropertyBagStream();
                                using var datMemoryStream = new MemoryStream(data);
                                _propertyBag.Read(datMemoryStream);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.Fail($"failure: {e}");
                        }
                    }
                }
            }
Esempio n. 5
0
 internal State(PropertyBagStream propertyBag)
 {
     _propertyBag = propertyBag;
 }
Esempio n. 6
0
 internal State(PropertyBagStream propBag)
 {
     PropertyBagBinary = propBag;
 }
        private State CreateNewOcxState(State oldOcxState)
        {
            this.NoComponentChangeEvents++;
            try
            {
                if (this.GetOcState() < 2)
                {
                    return null;
                }
                try
                {
                    PropertyBagStream pPropBag = null;
                    if (this.iPersistPropBag != null)
                    {
                        pPropBag = new PropertyBagStream();
                        this.iPersistPropBag.Save(pPropBag, true, true);
                    }
                    MemoryStream dataStream = null;
                    switch (this.storageType)
                    {
                        case 0:
                        case 1:
                            dataStream = new MemoryStream();
                            if (this.storageType != 0)
                            {
                                break;
                            }
                            this.iPersistStream.Save(new System.Windows.Forms.UnsafeNativeMethods.ComStreamFromDataStream(dataStream), true);
                            goto Label_00A9;

                        case 2:
                            if (oldOcxState == null)
                            {
                                return null;
                            }
                            return oldOcxState.RefreshStorage(this.iPersistStorage);

                        default:
                            return null;
                    }
                    this.iPersistStreamInit.Save(new System.Windows.Forms.UnsafeNativeMethods.ComStreamFromDataStream(dataStream), true);
                Label_00A9:
                    if (dataStream != null)
                    {
                        return new State(dataStream, this.storageType, this, pPropBag);
                    }
                    if (pPropBag != null)
                    {
                        return new State(pPropBag);
                    }
                }
                catch (Exception)
                {
                }
            }
            finally
            {
                this.NoComponentChangeEvents--;
            }
            return null;
        }
Esempio n. 8
0
            /**
             * Constructor used in deserialization
             */
            protected State(SerializationInfo info, StreamingContext context) {
                SerializationInfoEnumerator sie = info.GetEnumerator();
                if (sie == null) {
                    return;
                }
                for (; sie.MoveNext();) {
                    if (String.Compare(sie.Name, "Data", true, CultureInfo.InvariantCulture) == 0) {
                        try {
                            byte[] dat = (byte[])sie.Value;
                            if (dat != null) {
                                InitializeFromStream(new MemoryStream(dat));
                            }

                        }
                        catch (Exception e) {
                            Debug.Fail("failure: " + e.ToString());
                        }
                    }
                    else if (String.Compare(sie.Name, "PropertyBagBinary", true, CultureInfo.InvariantCulture) == 0) {
                        try {
                            Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "Loading up property bag from stream...");
                            byte[] dat = (byte[])sie.Value;
                            if (dat != null) {
                                this.propBag = new PropertyBagStream();
                                propBag.Read(new MemoryStream(dat));
                            }

                        }
                        catch (Exception e) {
                            Debug.Fail("failure: " + e.ToString());
                        }
                    }
                }
            }
Esempio n. 9
0
 internal State(PropertyBagStream propBag) {
     this.propBag = propBag;
 }
Esempio n. 10
0
 // create on save from ipersist stream
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 internal State(MemoryStream ms, int storageType, AxHost ctl, PropertyBagStream propBag) {
     type = storageType;
     this.propBag = propBag;
     // dangerous?
     length = (int)ms.Length;
     this.ms = ms;
     this.manualUpdate = ctl.GetAxState(AxHost.manualUpdate);
     this.licenseKey = ctl.GetLicenseKey();
 }
Esempio n. 11
0
        private State CreateNewOcxState(State oldOcxState) {
            NoComponentChangeEvents++;

            try {
                if (GetOcState() < OC_RUNNING) {
                    return null;
                }

                try {
                    PropertyBagStream propBag = null;

                    if (iPersistPropBag != null) {
                        propBag = new PropertyBagStream();
                        iPersistPropBag.Save(propBag, true, true);
                    }

                    MemoryStream ms = null;
                    switch (storageType) {
                        case STG_STREAM:
                        case STG_STREAMINIT:
                            ms = new MemoryStream();
                            if (storageType == STG_STREAM) {
                                iPersistStream.Save(new UnsafeNativeMethods.ComStreamFromDataStream(ms), true);
                            }
                            else {
                                iPersistStreamInit.Save(new UnsafeNativeMethods.ComStreamFromDataStream(ms), true);
                            }
                            break;
                        case STG_STORAGE:
                            Debug.Assert(oldOcxState != null, "we got to have an old state which holds out scribble storage...");
                            if (oldOcxState != null) return oldOcxState.RefreshStorage(iPersistStorage);
                            return null;
                        default:
                            Debug.Fail("unknown storage type.");
                            return null;
                    }
                    if (ms != null) {
                        return new State(ms, storageType, this, propBag);
                    }
                    else if (propBag != null) {
                        return new State(propBag);
                    }
                }
                catch (Exception e) {
                    Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "Could not create new OCX State: " + e.ToString());
                }
            }
            finally {
                NoComponentChangeEvents--;
            }

            return null;
        }