示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T ReadGeneric <T>()
        {
            ITypeSerializer <T> serializer = InternalTypeCache <T> .Serializer;

            if (serializer is IBuiltinTypeSerializer)
            {
                return(serializer.Deserialize(ref this));
            }
            else
            {
                ObjectType type = ReadTypeFromCachedTag();
                int        len  = ReadLengthByType(type);

                if (len < 0)
                {
                    throw new InvalidCastException(string.Format(Resources.InvalidCastFormat, type, typeof(T).AssemblyQualifiedName));
                }

                if (m_ReadCount + len > m_Size)
                {
                    throw new StreamTooShortException(Resources.StreamTooShort);
                }

                AccelReader reader = new AccelReader(m_Source + m_ReadCount, len, m_Encoding, m_IsLittleEndian);
                m_ReadCount += len;
                return(serializer.Deserialize(ref reader));
            }
        }
        public T ContentAs <T>()
        {
            //basic GET operation
            if (OpCode == OpCode.Get)
            {
                var bodyOffset = Header.BodyOffset;
                var length     = _contentBytes.Length - Header.BodyOffset;
                return(_transcoder.Decode <T>(_contentBytes, bodyOffset, length, Flags, OpCode));
            }

            //oh mai, its a projection
            ParseSpecs();

            var root = new JObject();

            foreach (var spec in _specs)
            {
                var content    = _serializer.Deserialize <JToken>(spec.Bytes, 0, spec.Bytes.Length);
                var projection = CreateProjection(spec.Path, content);

                try
                {
                    root.Add(projection.First); //hacky should be improved later
                }
                catch (Exception e)
                {
                    //ignore for now - these are cases where a root attribute is already mapped
                    //for example "attributes" and "attributes.hair" will cause exceptions
                }
            }
            return(root.ToObject <T>());
        }
        public T ContentAs <T>(int index)
        {
            EnsureNotDisposed();

            var response = _bytes.Memory.Slice(HeaderOffsets.HeaderLength);

            var operationSpecs = new List <OperationSpec>();

            for (;;)
            {
                var bodyLength = ByteConverter.ToInt32(response.Span.Slice(2));
                var payLoad    = response.Slice(6, bodyLength);

                var command = new MutateInSpec
                {
                    Status      = (ResponseStatus)ByteConverter.ToUInt16(response.Span),
                    ValueIsJson = payLoad.Span.IsJson(),
                    Bytes       = payLoad
                };
                operationSpecs.Add(command);

                response = response.Slice(6 + bodyLength);

                if (response.Length <= 0)
                {
                    break;
                }
            }

            var spec = operationSpecs[index];

            return(_serializer.Deserialize <T>(spec.Bytes));
        }
示例#4
0
        void ICustomDataItem.Deserialize(ITypeSerializer handler, DataCollection data)
        {
            DataItem items = (DataItem)data.Extract("Items");

            handler.Deserialize(this, data);
            IProgressMonitor monitor = handler.SerializationContext.ProgressMonitor;

            if (monitor == null)
            {
                monitor = new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor();
            }
            if (items != null)
            {
                string baseDir = Path.GetDirectoryName(handler.SerializationContext.BaseFile);
                monitor.BeginTask(null, items.ItemData.Count);
                try {
                    foreach (DataValue item in items.ItemData)
                    {
                        string        file = Path.Combine(baseDir, item.Value);
                        WorkspaceItem it   = Services.ProjectService.ReadWorkspaceItem(monitor, file);
                        if (it != null)
                        {
                            Items.Add(it);
                        }
                        monitor.Step(1);
                    }
                } finally {
                    monitor.EndTask();
                }
            }
        }
示例#5
0
        public override Array Deserialize(System.IO.Stream stream)
        {
            int length = stream.ReadByte();

            if (length == 254)
            {
                ushort t;
                ReadValue(stream, out t);
                length = t;
            }
            if (length == 255)
            {
                ReadValue(stream, out length);
            }

            var array = Array.CreateInstance(baseType, length);

            if (length > 0)
            {
                int index = 0;
                while (index < length)
                {
                    var obj = serializer.Deserialize(stream);
                    array.SetValue(obj, index++);
                }
            }
            return(array);
        }
        public void Deserialize(object obj, ITypeSerializer handler, DataCollection data)
        {
            //find whether is was marked as FileCopy
            DataValue value      = data ["buildaction"] as DataValue;
            bool      isFileCopy = value != null && value.Value == "FileCopy";

            handler.Deserialize(obj, data);
            ProjectFile file = (ProjectFile)obj;

            //if it wasn't, no fancy migrations to do
            if (!isFileCopy)
            {
                return;
            }

            //if there were any deploy settings remaining in the project file, then the file isn't "copy to output"
            //but instead should be marked to deploy
            foreach (string key in keys)
            {
                if (file.ExtendedProperties.Contains(key))
                {
                    file.CopyToOutputDirectory = FileCopyMode.None;
                    file.ExtendedProperties ["DeployService.Deploy"] = true;
                    return;
                }
            }
        }
示例#7
0
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            DataItem filtersItem = data.Extract("filters") as DataItem;

            if ((filtersItem != null) && (filtersItem.HasItemData))
            {
                foreach (DataItem item in filtersItem.ItemData)
                {
                    string filter              = ((DataValue)item.ItemData ["string"]).Value;
                    string typeString          = ((DataValue)item.ItemData ["type"]).Value;
                    ToolboxItemFilterType type = (ToolboxItemFilterType)Enum.Parse(typeof(ToolboxItemFilterType), typeString);

                    itemFilters.Add(new ToolboxItemFilterAttribute(filter, type));
                }
            }

            DataItem iconItem = data.Extract("icon") as DataItem;

            if (iconItem != null)
            {
                DataValue iconData = (DataValue)iconItem ["enc"];
                this.icon = new Gdk.Pixbuf(Convert.FromBase64String(iconData.Value));
            }

            handler.Deserialize(this, data);
        }
        protected T SerializeDeserialize <T>(ITypeSerializer serializer, T value)
        {
            var buffer = new BMSByte();

            serializer.Serialize(value, buffer);
            buffer.MoveStartIndex(-buffer.StartIndex());
            return((T)serializer.Deserialize(buffer));
        }
示例#9
0
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            handler.Deserialize(this, data);

            Init();

            referenceCollection.InitRefCollection(tempProjectDependencies, tempIncludes);
        }
示例#10
0
        public T ContentAs <T>()
        {
            EnsureNotDisposed();

            //basic GET or other non-projection operation
            if (OpCode == OpCode.Get || OpCode == OpCode.ReplicaRead || OpCode == OpCode.GetL || OpCode == OpCode.GAT)
            {
                return(_transcoder.Decode <T>(_contentBytes.Memory.Slice(Header.BodyOffset), Flags, OpCode));
            }

            //oh mai, its a projection
            ParseSpecs();

            // normal GET
            if (_specs.Count == 1 && _projectList?.Count == 0)
            {
                var spec = _specs[0];
                return(_transcoder.Decode <T>(spec.Bytes, Flags, OpCode.Get));
            }

            var root = new JObject();

            foreach (var spec in _specs)
            {
                var content = _serializer.Deserialize <JToken>(spec.Bytes);
                if (spec.OpCode == OpCode.Get)
                {
                    //a full doc is returned if the projection count exceeds the server limit
                    //so we remove any non-requested fields from the content returned.
                    if (_projectList?.Count > 16)
                    {
                        foreach (var child in content.Children())
                        {
                            if (_projectList.Contains(child.Path))
                            {
                                root.Add(child);
                            }
                        }

                        //root projection for empty path
                        return(root.ToObject <T>());
                    }
                }
                var projection = CreateProjection(spec.Path, content);

                try
                {
                    root.Add(projection.First);
                }
                catch (Exception e)
                {
                    //these are cases where a root attribute is already mapped
                    //for example "attributes" and "attributes.hair" will cause exceptions
                    Log.LogInformation(e, "Deserialization failed.");
                }
            }
            return(root.ToObject <T>());
        }
示例#11
0
        public T ContentAs <T>(int index)
        {
            if (index < 0 || index >= _specs.Count)
            {
                throw new InvalidIndexException($"The index provided is out of range: {index}.");
            }
            var spec = _specs[index];

            return(_serializer.Deserialize <T>(spec.Bytes));
        }
示例#12
0
 public static Serializer FromTypeSerializer<T>(ITypeSerializer<T> serializer)
 {
     return new Serializer()
     {
         TargetType = typeof(T),
         IsGeneral = false,
         SerializeFunction = obj => serializer.Serialize((T)obj),
         DeserializeFunction = (data, _) => serializer.Deserialize(data)
     };
 }
示例#13
0
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            handler.Deserialize(this, data);

            foreach (var p in tempIncludes)
            {
                LocalIncludeCache.Add(p);
            }

            // Parse local includes
            DCompilerConfiguration.UpdateParseCacheAsync(LocalIncludeCache);
        }
        public void TypeSerializer(Type type, ITypeSerializer typeSerializer)
        {
            for (var i = 0; i < 100000; i++)
            {
                var serializedType = typeSerializer.Serialize(type);

                _testOutputHelper.WriteLine(serializedType);

                var deserializedType = typeSerializer.Deserialize(serializedType);

                Assert.Equal(type, deserializedType);
            }
        }
 public void Deserialize(ITypeSerializer handler, DataCollection data)
 {
     handler.Deserialize((object)this, data);
     foreach (DataNode dataNode in data)
     {
         DataItem dataItem = dataNode as DataItem;
         if (dataItem != null)
         {
             this.Timelines.Add(handler.SerializationContext.Serializer.DataContext.GetConfigurationDataType(dataNode.Name).Deserialize(handler.SerializationContext, (object)null, (DataNode)dataItem) as TimelineData);
         }
     }
     this.ExtendedProperties.Clear();
 }
示例#16
0
        public object ReadArray(System.IO.Stream stream, int length, ITypeSerializer serializer)
        {
            int index = 0;
            var array = new BTCls[length];

            while (index < length)
            {
                var obj = serializer.Deserialize(stream);

                array[index++] = (BTCls)obj;
            }
            return(array);
        }
		void ICustomDataItem.Deserialize (ITypeSerializer handler, DataCollection data)
		{
			handler.Deserialize (this, data);
			if (data["Url"] == null) {
				string dir = ((DataValue)data ["Dir"]).Value;
				string user = ((DataValue)data ["User"]).Value;
				string server = ((DataValue)data ["Server"]).Value;
				string method = ((DataValue)data ["Method"]).Value;
				int port = int.Parse (((DataValue)data ["Port"]).Value);
				UriBuilder ub = new UriBuilder (method, server, port, dir);
				url = ub.ToString ();
			}
			CreateUri ();
		}
 public void Deserialize(ITypeSerializer handler, DataCollection data)
 {
     handler.Deserialize(this, data);
     foreach (DataNode dataNode in data)
     {
         DataItem dataItem = dataNode as DataItem;
         if (dataItem != null)
         {
             DataType     configurationDataType = handler.SerializationContext.Serializer.DataContext.GetConfigurationDataType(dataNode.Name);
             TimelineData item = configurationDataType.Deserialize(handler.SerializationContext, null, dataItem) as TimelineData;
             this.Timelines.Add(item);
         }
     }
     base.ExtendedProperties.Clear();
 }
示例#19
0
 void ICustomDataItem.Deserialize(ITypeSerializer handler, DataCollection data)
 {
     handler.Deserialize(this, data);
     if (data["Url"] == null)
     {
         string     dir    = ((DataValue)data ["Dir"]).Value;
         string     user   = ((DataValue)data ["User"]).Value;
         string     server = ((DataValue)data ["Server"]).Value;
         string     method = ((DataValue)data ["Method"]).Value;
         int        port   = int.Parse(((DataValue)data ["Port"]).Value);
         UriBuilder ub     = new UriBuilder(method, server, port, dir);
         url = ub.ToString();
     }
     CreateUri();
 }
示例#20
0
 /// <summary>
 /// 将Base64字符串反序列化成对象
 /// </summary>
 /// <param name="base64String"></param>
 /// <returns></returns>
 public static T GetSerializerData(string base64String)
 {
     try
     {
         var data = Base64Serialzier.FromBase64String(base64String);
         data = instance.Decode(data);
         using (var stream = new MemoryStream(data))
         {
             return(serializer.Deserialize(stream) as T);
         }
     }
     catch //(Exception ex)
     {
     }
     return(null);
 }
        /// <summary>
        /// Adds the objects found in the stream to given model
        /// </summary>
        /// <param name="reader"></param>
        public List <IModelObject> Deserialize(StreamReader reader)
        {
            var ret  = new List <IModelObject>();
            var strm = new SectionedStreamReader(reader);

            while (strm.CurrentSection == ObjectsSection)
            {
                var id       = int.Parse(strm.ReadLine());
                var typeName = strm.ReadLine();
                var type     = typeSerializer.Deserialize(typeName);
                if (type == null)
                {
                    Console.WriteLine("Unexisting type: " + typeName);
                    continue;
                }
                try
                {
                    var obj = (IModelObject)Activator.CreateInstance(type);
                    myObjectDictionary.setObjectID(obj, id);

                    ret.Add(obj);
                }
                catch (Exception ex)
                {
                    DI.Get <IErrorLogger>().Log(ex, "Cant create model object");
                }
            }

            while (strm.CurrentSection == AttributesSection)
            {
                var id  = int.Parse(strm.ReadLine());
                var obj = myObjectDictionary.getObjectByID(id);
                if (obj == null)
                {
                    Console.WriteLine("Unknown object with ID: " + id);
                    // Can be caused by corrupt save, or by an unexisting type for which the object was not loaded.
                    continue;
                }

                DeserializeAttributes(obj, strm);
            }
            return(ret);
        }
示例#22
0
        protected virtual void DeserializeAttribMember(XmlReader reader,
                                                       TypeInfo info,
                                                       Dictionary <TypeMemberInfo, object> memberValues)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            if (memberValues == null)
            {
                throw new ArgumentNullException("memberValues");
            }
            if (!info.MemberInfoByEntityName.ContainsKey(reader.Name))
            {
                return;
            }
            if (!info.MemberInfoByEntityName[reader.Name].IsAttribute)
            {
                return;
            }
            var memberInfo = info.MemberInfoByEntityName[reader.Name];

            // Attempt to fetch a custom type serializer
            ITypeSerializer typeSerializer =
                Factory.CallMethod(new[] { memberInfo.DataType }, "GetTypeSerializer") as ITypeSerializer;

            if (typeSerializer != null)
            {
                memberValues[memberInfo] = typeSerializer.Deserialize(reader, memberInfo.DataType);
            }
            else

            // Since there was no bound custom type serializer we default to the GenericTypeSerializer
            {
                var defaultSerializer = Factory.GetDefaultSerializer();
                memberValues[memberInfo] = defaultSerializer.Deserialize(reader, memberInfo.DataType);
            }
        }
        public object ReadBody(VoxBinaryReader reader)
        {
            var length = reader.ReadVariableInt();

            reader.HandleEnterInnerBuffer(length);
            try {
                var slotCount   = reader.ReadVariableInt();
                var readerThing = new ReaderThing(thisIsTotesTheRealLegitThingReaderWriterThing, reader, slotCount);
                try {
                    var subject = Activator.CreateInstance(typeof(TUserType));
                    userTypeSerializer.Deserialize(readerThing, (TUserType)subject);
                    return(subject);
                } catch (Exception e) {
                    logger.Error($"Failed to instantiate or deserialize instance of type {typeof(TUserType).Name}.");
                    throw;
                }
            } finally {
                reader.HandleLeaveInnerBuffer();
            }
        }
示例#24
0
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            string baseFile = handler.SerializationContext.BaseFile;

            handler.Deserialize((object)this, data);
            handler.SerializationContext.BaseFile = (string)this.BaseDirectory.Combine(new string[1]
            {
                "TempAppendFileName.Folder"
            });
            foreach (DataNode dataNode in data)
            {
                DataItem dataItem = dataNode as DataItem;
                if (dataItem != null)
                {
                    this.Items.Add(handler.SerializationContext.Serializer.DataContext.GetConfigurationDataType(dataNode.Name).Deserialize(handler.SerializationContext, (object)null, (DataNode)dataItem) as ResourceItem);
                }
            }
            this.ExtendedProperties.Clear();
            handler.SerializationContext.BaseFile = baseFile;
        }
示例#25
0
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            DataItem item = new DataItem();

            item.Name = "SolutionConfiguration";
            DataCollection col = item.ItemData;

            foreach (DataNode val in data)
            {
                if (val.Name != "name" && val.Name != "ctype" && val.Name != "Entry")
                {
                    col.Add(val);
                }
            }

            handler.Deserialize(this, data);

            if (data.Count > 0)
            {
                solutionConfiguration = new SolutionConfiguration(name);
                handler.SerializationContext.Serializer.Deserialize(solutionConfiguration, item);
            }
        }
示例#26
0
        public T ContentAs <T>(int index)
        {
            var response          = _bytes;
            var statusOffset      = 24;//Header.BodyOffset;
            var valueLengthOffset = statusOffset + 2;
            var valueOffset       = statusOffset + 6;

            var operationSpecs = new List <OperationSpec>();

            for (;;)
            {
                var bodyLength = _converter.ToInt32(response, valueLengthOffset);
                var payLoad    = new byte[bodyLength];
                Buffer.BlockCopy(response, valueOffset, payLoad, 0, bodyLength);

                var command = new OperationSpec
                {
                    Status      = (ResponseStatus)_converter.ToUInt16(response, statusOffset),
                    ValueIsJson = payLoad.IsJson(0, bodyLength - 1),
                    Bytes       = payLoad
                };
                operationSpecs.Add(command);

                statusOffset      = valueOffset + bodyLength;
                valueLengthOffset = statusOffset + 2;
                valueOffset       = statusOffset + 6;

                if (valueOffset >= response.Length)
                {
                    break;
                }
            }

            var spec = operationSpecs[index];

            return(_serializer.Deserialize <T>(spec.Bytes, 0, spec.Bytes.Length));
        }
示例#27
0
        // if MtouchDebug element is not present, this handler migrates args
        // and sets default values for the new Mtouch* properties
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            var argsToMigrate   = data.Extract("ExtraMtouchArgs") as DataValue;
            var mtouchDebugData = data.Extract("MtouchDebug") as DataValue;

            handler.Deserialize(this, data);

            if (mtouchDebugData == null || string.IsNullOrEmpty(mtouchDebugData.Value))
            {
                if (Name == "Debug")
                {
                    MtouchDebug = true;
                    if (IsSimPlatform)
                    {
                        MtouchLink = MtouchLinkMode.None;
                    }
                }
                if (argsToMigrate != null && string.IsNullOrEmpty(argsToMigrate.Value))
                {
                    if (argsToMigrate.Value.Contains("-debug"))
                    {
                        MtouchDebug = true;
                    }
                    if (argsToMigrate.Value.Contains("-nolink"))
                    {
                        MtouchLink = MtouchLinkMode.None;
                    }
                    MtouchExtraArgs = new StringBuilder(argsToMigrate.Value)
                                      .Replace("-nolink", "").Replace("-linksdkonly", "").Replace("-debug", "").Replace("  ", " ")
                                      .ToString();
                }
            }
            else
            {
                MtouchDebug = mtouchDebugData.Value.Equals("true", StringComparison.OrdinalIgnoreCase);
            }
        }
		public void Deserialize (object obj, ITypeSerializer handler, DataCollection data)
		{
			handler.Deserialize (obj, data);
		}
		// if MtouchDebug element is not present, this handler migrates args
		// and sets default values for the new Mtouch* properties
		public void Deserialize (ITypeSerializer handler, DataCollection data)
		{
			var argsToMigrate = data.Extract ("ExtraMtouchArgs") as DataValue;
			var mtouchDebugData = data.Extract ("MtouchDebug") as DataValue;
			handler.Deserialize (this, data);
			
			if (mtouchDebugData == null || string.IsNullOrEmpty (mtouchDebugData.Value)) {
				if (Name == "Debug") {
					MtouchDebug = true;
					if (Platform == IPhoneProject.PLAT_SIM)
						MtouchLink = MtouchLinkMode.None;
				}
				if (argsToMigrate != null && string.IsNullOrEmpty (argsToMigrate.Value)) {
					if (argsToMigrate.Value.Contains ("-debug"))
						MtouchDebug = true;
					if (argsToMigrate.Value.Contains ("-nolink"))
						MtouchLink = MtouchLinkMode.None;
					MtouchExtraArgs = new StringBuilder (argsToMigrate.Value)
						.Replace ("-nolink", "").Replace ("-linksdkonly", "").Replace ("-debug", "").Replace ("  ", " ")
						.ToString ();
				}
			} else {
				MtouchDebug = mtouchDebugData.Value.Equals ("true", StringComparison.OrdinalIgnoreCase);
			}
		}
        public virtual void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            DataValue ac = null;
            DataItem confItem = data ["Configurations"] as DataItem;
            if (confItem != null)
                ac = (DataValue) confItem.ItemData.Extract ("active");

            handler.Deserialize (this, data);
            if (ac != null)
                activeConfiguration = GetConfiguration (ac.Value);
        }
示例#31
0
 public static T?Deserialize <T>(this ITypeSerializer typeSerializer, byte[] buffer, int offset, int length)
 {
     return(typeSerializer.Deserialize <T>(buffer.AsMemory(offset, length)));
 }
示例#32
0
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            handler.Deserialize(this, data);

            foreach (var p in tempIncludes)
                LocalIncludeCache.Add(p);

            // Parse local includes
            DCompilerConfiguration.UpdateParseCacheAsync(LocalIncludeCache);
        }
示例#33
0
        public T ContentAs <T>(int index)
        {
            var spec = _specs[index];

            return(_serializer.Deserialize <T>(spec.Bytes));
        }
 void ICustomDataItem.Deserialize(ITypeSerializer handler, DataCollection data)
 {
     DataValue refto = data.Extract ("refto") as DataValue;
     handler.Deserialize (this, data);
     if (refto != null) {
         reference = refto.Value;
         if (referenceType == ReferenceType.Assembly) {
             string basePath = Path.GetDirectoryName (handler.SerializationContext.BaseFile);
             reference = Runtime.FileUtilityService.RelativeToAbsolutePath (basePath, reference);
         }
     }
 }
		public void Deserialize (ITypeSerializer handler, DataCollection data)
		{
			DataItem item = new DataItem ();
			item.Name = "SolutionConfiguration";
			DataCollection col = item.ItemData;
			
			foreach (DataNode val in data) {
				if (val.Name != "name" && val.Name != "ctype" && val.Name != "Entry")
					col.Add (val);
			}
			
			handler.Deserialize (this, data);
			
			if (data.Count > 0) {
				solutionConfiguration = new SolutionConfiguration (name);
				handler.SerializationContext.Serializer.Deserialize (solutionConfiguration, item);
			}
		}
		public void Deserialize (object obj, ITypeSerializer handler, DataCollection data)
		{
			//find whether is was marked as FileCopy
			DataValue value = data ["buildaction"] as DataValue;
			bool isFileCopy = value != null && value.Value == "FileCopy";
			
			handler.Deserialize (obj, data);
			ProjectFile file = (ProjectFile) obj;
			
			//if it wasn't, no fancy migrations to do
			if (!isFileCopy)
				return;
			
			//if there were any deploy settings remaining in the project file, then the file isn't "copy to output"
			//but instead should be marked to deploy
			foreach (string key in keys) {
				if (file.ExtendedProperties.Contains (key)) {
					file.CopyToOutputDirectory = FileCopyMode.None;
					file.ExtendedProperties ["DeployService.Deploy"] = true;
					return;
				}
			}
		}
示例#37
0
        public virtual void Deserialize(object obj, ITypeSerializer handler, DataCollection data)
        {
            if (obj is ProjectFile)
            {
                ProjectFile pf = (ProjectFile)obj;

                //Map the old FileCopy action to the Content BuildAction with CopyToOutputDirectory set to "always"
                //BuildActionDataType handles mapping the BuildAction to "Content"
                DataValue value      = data ["buildaction"] as DataValue;
                bool      isFileCopy = value != null && value.Value == "FileCopy";

                DataValue resourceId = data.Extract("resource_id") as DataValue;

                handler.Deserialize(obj, data);
                if (isFileCopy)
                {
                    pf.CopyToOutputDirectory = FileCopyMode.Always;
                }

                if (resourceId != null)
                {
                    pf.ResourceId = resourceId.Value;
                }
            }
            else if (obj is SolutionEntityItem)
            {
                DataValue ac       = null;
                DataItem  confItem = data ["Configurations"] as DataItem;
                if (confItem != null)
                {
                    ac = (DataValue)confItem.ItemData.Extract("active");
                }

                DataItem items = data.Extract("Items") as DataItem;
                if (items != null)
                {
                    ReadItems(handler, (SolutionEntityItem)obj, items);
                }

                handler.Deserialize(obj, data);
                if (ac != null)
                {
                    SolutionEntityItem item = (SolutionEntityItem)obj;
                    item.DefaultConfigurationId = ac.Value;
                }
                DotNetProject np = obj as DotNetProject;
                if (np != null)
                {
                    // Import the framework version
                    TargetFrameworkMoniker fx = null;
                    DataValue vfx             = data["targetFramework"] as DataValue;
                    if (vfx != null)
                    {
                        fx = TargetFrameworkMoniker.Parse(vfx.Value);
                    }
                    else
                    {
                        vfx = data ["clr-version"] as DataValue;
                        if (vfx != null && vfx.Value == "Net_2_0")
                        {
                            fx = TargetFrameworkMoniker.NET_2_0;
                        }
                        else if (vfx != null && vfx.Value == "Net_1_1")
                        {
                            fx = TargetFrameworkMoniker.NET_1_1;
                        }
                    }
                    if (fx != null)
                    {
                        np.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework(fx);
                    }

                    // Get the compile target from one of the configurations
                    if (np.Configurations.Count > 0)
                    {
                        np.CompileTarget = (CompileTarget)Enum.Parse(typeof(CompileTarget), (string)np.Configurations [0].ExtendedProperties ["Build/target"]);
                    }
                }
            }
            else if (obj is ProjectReference)
            {
                ProjectReference pref  = (ProjectReference)obj;
                DataValue        refto = data.Extract("refto") as DataValue;
                handler.Deserialize(obj, data);
                if (refto != null)
                {
                    pref.Reference = refto.Value;
                    if (pref.ReferenceType == ReferenceType.Assembly)
                    {
                        string basePath = Path.GetDirectoryName(handler.SerializationContext.BaseFile);
                        pref.Reference = FileService.RelativeToAbsolutePath(basePath, pref.Reference);
                    }
                }
            }
            else
            {
                handler.Deserialize(obj, data);
            }
        }
 public void Deserialize(ITypeSerializer handler, DataCollection data)
 {
     handler.Deserialize(this, data);
 }
示例#39
0
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            handler.Deserialize (this, data);

            foreach (var p in tempIncludes)
                LocalIncludeCache.ParsedDirectories.Add (ProjectBuilder.EnsureCorrectPathSeparators (p));
        }
		public virtual void Deserialize (object obj, ITypeSerializer handler, DataCollection data)
		{
			if (obj is ProjectFile) {
				ProjectFile pf = (ProjectFile) obj;
				
				//Map the old FileCopy action to the Content BuildAction with CopyToOutputDirectory set to "always"
				//BuildActionDataType handles mapping the BuildAction to "Content"
				DataValue value = data ["buildaction"] as DataValue;
				bool isFileCopy = value != null && value.Value == "FileCopy";
				
				DataValue resourceId = data.Extract ("resource_id") as DataValue;
				
				handler.Deserialize (obj, data);
				if (isFileCopy)
					pf.CopyToOutputDirectory = FileCopyMode.Always;
				
				if (resourceId != null)
					pf.ResourceId = resourceId.Value;
			}
			else if (obj is SolutionEntityItem) {
				DataValue ac = null;
				DataItem confItem = data ["Configurations"] as DataItem;
				if (confItem != null)
					ac = (DataValue) confItem.ItemData.Extract ("active");
					
				DataItem items = data.Extract ("Items") as DataItem;
				if (items != null)
					ReadItems (handler, (SolutionEntityItem)obj, items);
				
				handler.Deserialize (obj, data);
				if (ac != null) {
					SolutionEntityItem item = (SolutionEntityItem) obj;
					item.DefaultConfigurationId = ac.Value;
				}
				DotNetProject np = obj as DotNetProject;
				if (np != null) {
					// Import the framework version
					TargetFrameworkMoniker fx = null;
					DataValue vfx = data["targetFramework"] as DataValue;
					if (vfx != null)
						fx = TargetFrameworkMoniker.Parse (vfx.Value);
					else {
						vfx = data ["clr-version"] as DataValue;
						if (vfx != null && vfx.Value == "Net_2_0")
							fx = TargetFrameworkMoniker.NET_2_0;
						else if (vfx != null && vfx.Value == "Net_1_1")
							fx = TargetFrameworkMoniker.NET_1_1;
					}
					if (fx != null)
						np.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework (fx);

					// Get the compile target from one of the configurations
					if (np.Configurations.Count > 0)
						np.CompileTarget = (CompileTarget) Enum.Parse (typeof(CompileTarget), (string) np.Configurations [0].ExtendedProperties ["Build/target"]);
				}
			}
			else if (obj is ProjectReference) {
				ProjectReference pref = (ProjectReference) obj;
				DataValue refto = data.Extract ("refto") as DataValue;
				handler.Deserialize (obj, data);
				if (refto != null) {
					pref.Reference = refto.Value;
					if (pref.ReferenceType == ReferenceType.Assembly) {
						string basePath = Path.GetDirectoryName (handler.SerializationContext.BaseFile);
						pref.Reference = FileService.RelativeToAbsolutePath (basePath, pref.Reference);
					}
				}
			} else
				handler.Deserialize (obj, data);
		}
 /// <summary>
 /// Maps a single row.
 /// </summary>
 /// <typeparam name="T">The <see cref="IViewResult{T}"/>'s Type paramater.</typeparam>
 /// <param name="stream">The <see cref="Stream"/> results of the query.</param>
 /// <returns>An object deserialized to it's T type.</returns>
 public T Map <T>(Stream stream)
 {
     return(_serializer.Deserialize <T>(stream));
 }
示例#42
0
文件: DProject.cs 项目: aBothe/Mono-D
        public void Deserialize(ITypeSerializer handler, DataCollection data)
        {
            handler.Deserialize (this, data);

            referenceCollection.InitRefCollection (tempProjectDependencies, tempIncludes);
        }
示例#43
0
		void ICustomDataItem.Deserialize (ITypeSerializer handler, DataCollection data)
		{
			DataItem items = (DataItem) data.Extract ("Items");
			handler.Deserialize (this, data);
			ProgressMonitor monitor = handler.SerializationContext.ProgressMonitor;
			if (monitor == null)
				monitor = new ProgressMonitor ();
			if (items != null) {
				string baseDir = Path.GetDirectoryName (handler.SerializationContext.BaseFile);
				monitor.BeginTask (null, items.ItemData.Count);
				try {
					foreach (DataValue item in items.ItemData) {
						string file = Path.Combine (baseDir, item.Value);
						WorkspaceItem it = Services.ProjectService.ReadWorkspaceItem (monitor, file).Result;
						if (it != null)
							Items.Add (it);
						monitor.Step (1);
					}
				} finally {
					monitor.EndTask ();
				}
			}
		}