Ejemplo n.º 1
0
        private IPersistable LoadObject(string name, IPersistable obj)
        {
            string   fileName = PersistenceUtils.GetFilename(_scope, _path, name, _extension);
            FileInfo file     = _scope.Context.GetResource(fileName).File;

            if (!file.Exists)
            {
                return(null);               // No such file
            }
            IPersistable result = obj;

            lock (this.SyncRoot)
            {
                using (FileStream fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    AMFReader reader   = new AMFReader(fs);
                    string    typeName = reader.ReadData() as string;
                    result = ObjectFactory.CreateInstance(typeName) as IPersistable;
                    //result.Path = GetObjectPath(name, result.Name);
                    //result = amfDeserializer.ReadData() as IPersistable;
                    result.Deserialize(reader);
                }
            }
            return(result);
        }
        public IPersistable CreateRIFObject(ObjectType objectType, ref IntermediateFormatReader context)
        {
            IPersistable persistObj = null;

            if (objectType == ObjectType.Null)
            {
                return(null);
            }
            Global.Tracer.Assert(TryCreateObject(objectType, out persistObj));
            persistObj.Deserialize(context);
            return(persistObj);
        }
Ejemplo n.º 3
0
        public IPersistable CreateRIFObject(Microsoft.ReportingServices.ReportIntermediateFormat.Persistence.ObjectType objectType, ref IntermediateFormatReader context)
        {
            IPersistable newObject = null;
            bool         flag      = false;
            bool         flag2     = false;

            for (int i = 0; i < m_objectCreators.Length; i++)
            {
                if (flag)
                {
                    break;
                }
                flag = m_objectCreators[i].TryCreateObject(objectType, out newObject);
            }
            if (!flag)
            {
                flag2 = true;
                BaseReference newReference = null;
                for (int j = 0; j < m_referenceCreators.Length; j++)
                {
                    if (flag)
                    {
                        break;
                    }
                    flag = m_referenceCreators[j].TryCreateReference(objectType, out newReference);
                }
                newObject = newReference;
            }
            if (flag)
            {
                newObject.Deserialize(context);
                if (flag2)
                {
                    BaseReference baseReference = (BaseReference)newObject;
                    newObject = baseReference.ScalabilityCache.PoolReference(baseReference);
                }
            }
            else
            {
                Global.Tracer.Assert(false, "Cannot create object of type: {0}", objectType);
            }
            return(newObject);
        }
Ejemplo n.º 4
0
        public void Start(Simian server)
        {
            this.server = server;

            LLSD llsd;

            try
            {
                XmlTextReader reader = new XmlTextReader(File.OpenRead(server.DataDir + "simiandata.xml"));
                llsd = LLSDParser.DeserializeXml(reader);
                reader.Close();
            }
            catch (FileNotFoundException)
            {
                return;
            }
            catch (Exception ex)
            {
                Logger.Log("Failed to load saved data: " + ex.Message, Helpers.LogLevel.Error);
                return;
            }

            if (llsd is LLSDMap)
            {
                LLSDMap dictionary = (LLSDMap)llsd;

                for (int i = 0; i < server.PersistentExtensions.Count; i++)
                {
                    IPersistable persistable = server.PersistentExtensions[i];

                    LLSD savedData;
                    if (dictionary.TryGetValue(persistable.ToString(), out savedData))
                    {
                        Logger.DebugLog("Loading saved data for " + persistable.ToString());
                        persistable.Deserialize(savedData);
                    }
                    else
                    {
                        Logger.DebugLog("No saved data found for " + persistable.ToString());
                    }
                }
            }
        }
        public IPersistable CreateRIFObject(AspNetCore.ReportingServices.ReportIntermediateFormat.Persistence.ObjectType objectType, ref IntermediateFormatReader context)
        {
            IPersistable persistable = null;
            bool         flag        = false;
            bool         flag2       = false;

            for (int i = 0; i < this.m_objectCreators.Length; i++)
            {
                if (flag)
                {
                    break;
                }
                flag = this.m_objectCreators[i].TryCreateObject(objectType, out persistable);
            }
            if (!flag)
            {
                flag2 = true;
                BaseReference baseReference = null;
                for (int j = 0; j < this.m_referenceCreators.Length; j++)
                {
                    if (flag)
                    {
                        break;
                    }
                    flag = this.m_referenceCreators[j].TryCreateReference(objectType, out baseReference);
                }
                persistable = baseReference;
            }
            if (flag)
            {
                persistable.Deserialize(context);
                if (flag2)
                {
                    BaseReference baseReference2 = (BaseReference)persistable;
                    persistable = baseReference2.ScalabilityCache.PoolReference(baseReference2);
                }
            }
            else
            {
                Global.Tracer.Assert(false, "Cannot create object of type: {0}", objectType);
            }
            return(persistable);
        }
Ejemplo n.º 6
0
        private IPersistable LoadObject(string name, IPersistable obj)
        {
            string   location = PersistenceUtils.GetFilename(base._scope, this._path, name, this._extension);
            FileInfo file     = base._scope.Context.GetResource(location).File;

            if (!file.Exists)
            {
                return(null);
            }
            IPersistable persistable = obj;

            lock (base.SyncRoot)
            {
                using (FileStream stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    AMFReader reader   = new AMFReader(stream);
                    string    typeName = reader.ReadData() as string;
                    persistable = ObjectFactory.CreateInstance(typeName) as IPersistable;
                    persistable.Deserialize(reader);
                }
            }
            return(persistable);
        }