当前位置: 首页>>代码示例>>C#>>正文


C# DataContract类代码示例

本文整理汇总了C#中DataContract的典型用法代码示例。如果您正苦于以下问题:C# DataContract类的具体用法?C# DataContract怎么用?C# DataContract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataContract类属于命名空间,在下文中一共展示了DataContract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddRemark

        public DataContract.RemarkResponse AddRemark(string employeeId, DataContract.Remark remark)
        {
            RemarkResponse response = new RemarkResponse();
            try
            {
                var result = _manager.AddRemark(employeeId, remark.ToDomainModel());
                if (result == null)
                {
                    response.Status.StatusCode = "500";
                    response.Status.Message = "Error in creating employee";

                    return response;
                }
                response.Remark = result.ToDataContract();
                return response;
            }
            catch (Exception ex)
            {

                ExceptionPolicy.HandleException("service.policy", ex);
                response.Status.StatusCode = "500";
                response.Status.Message = "Error in creating Employee";
                return response;
            }
        }
开发者ID:tavisca-dhruvas,项目名称:Training,代码行数:25,代码来源:EmployeeManagementService.cs

示例2: ListLugares

 public ResultadoMapa ListLugares(DataContract.PointDC tl, DataContract.PointDC br, byte zoom, FiltroMapa filtro)
 {
     if (zoom >= 8)
     {
         PersistenceManager persistence = new PersistenceManager();
         ICriteria criteria = persistence.CreateCriteria<Lugar>();
         List<Coordinate> coordenadas = new List<Coordinate>();
         coordenadas.Add(new Coordinate(tl.Longitud, tl.Latitud));
         coordenadas.Add(new Coordinate(br.Longitud, tl.Latitud));
         coordenadas.Add(new Coordinate(br.Longitud, br.Latitud));
         coordenadas.Add(new Coordinate(tl.Longitud, br.Latitud));
         coordenadas.Add(new Coordinate(tl.Longitud, tl.Latitud));
         Polygon p = new Polygon(new LinearRing(coordenadas.ToArray()));
         criteria.SetProjection(Projections.ProjectionList()
             .Add(Projections.Property<Lugar>(l => l.ID), "ID")
             .Add(Projections.Property<Lugar>(l => l.Posicion), "Point")
             .Add(Projections.Property<Lugar>(l => l.Nombre), "Nombre")
             );
         criteria.Add(SpatialRestrictions.Within("Posicion", p));
         criteria.SetResultTransformer(Transformers.AliasToBean<ItemLugar>());
         criteria.AddOrder(new Order(Projections.Property<Lugar>(l => l.Nombre), true));
         var list = criteria.List<ItemLugar>().ToList();
         HttpContext.Current.Session["Colegios"] = list;
         return new ResultadoMapa() { Items = list };
     }
     return new ResultadoMapa() { Items = new List<ItemLugar>() };
 }
开发者ID:desarrollandoAmericaLatina,项目名称:Taem,代码行数:27,代码来源:APIService.cs

示例3: Create

        public DataContract.EmployeeResponse Create(DataContract.Employee employee)
        {
            EmployeeResponse response = new EmployeeResponse();
            try
            {
                employee.JoiningDate = DateTime.UtcNow;
                var result = _manager.Create(employee.ToDomainModel());
                if (result == null)
                {
                    response.Status.StatusCode = "500";
                    response.Status.Message = "Error in creating employee";

                    return response;
                }
                response.Employee = result.ToDataContract();
                return response;
            }
            catch (Exception ex)
            {

                ExceptionPolicy.HandleException("service.policy", ex);
                response.Status.StatusCode = "500";
                response.Status.Message = "Error in creating Employee";
                return response;
            }
        }
开发者ID:tavisca-dhruvas,项目名称:Training,代码行数:26,代码来源:EmployeeManagementService.cs

示例4: XmlObjectSerializerWriteContextComplexJson

        public XmlObjectSerializerWriteContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract)
            : base(null, int.MaxValue, new StreamingContext(), true)

        {
            _jsonSerializer = serializer;
            this.rootTypeDataContract = rootTypeDataContract;
            this.serializerKnownTypeList = serializer.knownTypeList;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:XmlObjectSerializerWriteContextComplexJson.cs

示例5: Random

        int IBlogService.CreateEntry(DataContract.Entry entry)
        {
			var entity = new Entity.Entry()
			{
				Content = entry.Content,
				Name = entry.Title,
				Id = new Random().Next(1000)
			};
			return entity.Id;
        }
开发者ID:thebeekeeper,项目名称:Laurus.Blog,代码行数:10,代码来源:BlogService.cs

示例6: XmlObjectSerializerReadContextComplexJson

 public XmlObjectSerializerReadContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract)
     : base(serializer, serializer.MaxItemsInObjectGraph,
         new StreamingContext(StreamingContextStates.All),
         serializer.IgnoreExtensionDataObject)
 {
     this.rootTypeDataContract = rootTypeDataContract;
     this.serializerKnownTypeList = serializer.knownTypeList;
     this.dataContractSurrogate = serializer.DataContractSurrogate;
     this.dateTimeFormat = serializer.DateTimeFormat;
     this.useSimpleDictionaryFormat = serializer.UseSimpleDictionaryFormat;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:11,代码来源:XmlObjectSerializerReadContextComplexJson.cs

示例7:

		void IBlogService.AddEntry(int blogId, DataContract.Entry entry)
		{
			var entryEntity = new Entity.Entry()
			{
				Name = entry.Title,
				Content = entry.Content,
				//BlogId = blogId
			};
			if (_repository.Query<Entity.Blog>().Where(x => x.Id == blogId).Any())
			{
				_repository.Persist(entryEntity);
			}
		}
开发者ID:thebeekeeper,项目名称:Laurus.Blog,代码行数:13,代码来源:BlogService.cs

示例8: Translate

        public static void Translate(Repository.Item dbItem, DataContract.Item item)
        {
            dbItem.ItemAbstract = item.ItemAbstract;
            dbItem.ItemTitle = item.ItemTitle;
            dbItem.LastUpdated = DateTime.Now;

            if (item.Content != null)
            {
                dbItem.InternalUrl = item.Content.InternalUrl;
                dbItem.ExternalUrl = item.Content.ExternalUrl;
                dbItem.ItemText = item.Content.ItemText;
            }
        }
开发者ID:sirtristancomtedeartois,项目名称:note,代码行数:13,代码来源:ItemTranslator.cs

示例9: ChangePassword

 public bool ChangePassword(DataContract.ChangePasswordRequest request)
 {
     try
     {
         return _manager.ChangePassword(request.Email, request.OldPassword, request.NewPassword);
     }
     catch (Exception ex)
     {
         Exception newEx;
         var rethrow = ExceptionPolicy.HandleException("service.policy", ex, out newEx);
         return false;
     }
 }
开发者ID:ytokas,项目名称:Tavisca-Training-WCF-EMS,代码行数:13,代码来源:IdentityService.cs

示例10: Authenticate

        public DataContract.EmployeeResponse Authenticate(DataContract.Credentials credentials)
        {
            EmployeeResponse response = new EmployeeResponse();
            var result = _manager.Authenticate(credentials.EmailId, credentials.Password);
            if (result == null)
            {
                response.Status.StatusCode = "500";
                response.Status.Message = "Error in creating employee";

                return response;
            }
            response.Employee = result.ToDataContract();
            return response;
        }
开发者ID:tavisca-dhruvas,项目名称:Training,代码行数:14,代码来源:EmployeeManagementService.cs

示例11: Authenticate

 public DataContract.Employee Authenticate(DataContract.Credential credential)
 {
     try
     {
         var result = _manager.Authenticate(credential.ToDomainModel());
         if (result == null) return null;
         return result.ToDataContract();
     }
     catch (Exception ex)
     {
         var rethrow = ExceptionPolicy.HandleException("service.policy", ex);
         if (rethrow) throw;
         return null;
     }
 }
开发者ID:ytokas,项目名称:Tavisca-Training-WCF-EMS,代码行数:15,代码来源:IdentityService.cs

示例12: Create

 public DataContract.Employee Create(DataContract.Employee employee)
 {
     try
     {
         var result = _manager.Create(employee.ToDomainModel());
         if (result == null) return null;
         return result.ToDataContract();
     }
     catch (Exception ex)
     {
         Exception newEx;
         var rethrow = ExceptionPolicy.HandleException("service.policy", ex, out newEx);
         throw newEx;
     }
 }
开发者ID:ytokas,项目名称:Tavisca-Training-WCF-EMS,代码行数:15,代码来源:EmployeeManagementService.cs

示例13: AddRemark

 public DataContract.Remark AddRemark(string employeeId, DataContract.Remark remark)
 {
     try
     {
         var result = _manager.AddRemark(employeeId, remark.ToDomainModel());
         if (result == null) return null;
         return result.ToDataContract();
     }
     catch (Exception ex)
     {
         Exception newEx;
         var rethrow = ExceptionPolicy.HandleException("service.policy", ex, out newEx);
         throw newEx;
     }
 }
开发者ID:ytokas,项目名称:Tavisca-Training-WCF-EMS,代码行数:15,代码来源:EmployeeManagementService.cs

示例14: WriteCollectionToJson

		public void WriteCollectionToJson (XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, CollectionDataContract dataContract)
		{
			this.writer = xmlWriter;
			this.obj = obj;
			this.context = context;
			this.dataContract = dataContract;

			InitArgs (collectionContract.UnderlyingType);			

			// DemandMemberAccessPermission(memberAccessFlag);
			if (collectionContract.IsReadOnlyContract)
			{
				DataContract.ThrowInvalidDataContractException (collectionContract.SerializationExceptionMessage, null);
			}

			WriteCollection (collectionContract);
		}
开发者ID:psni,项目名称:mono,代码行数:17,代码来源:JsonFormatWriterGenerator_static.cs

示例15: WriteToJson

		public void WriteToJson (XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, ClassDataContract dataContract, XmlDictionaryString [] memberNames)
		{
			this.writer = xmlWriter;
			this.obj = obj;
			this.context = context;
			this.dataContract = dataContract;
			this.memberNames = memberNames;

			InitArgs (classContract.UnderlyingType);

			// DemandSerializationFormatterPermission (classContract) - irrelevant
			// DemandMemberAccessPermission (memberAccessFlag) - irrelevant

			if (classContract.IsReadOnlyContract)
			{
				DataContract.ThrowInvalidDataContractException (classContract.SerializationExceptionMessage, null);
			}

			WriteClass (classContract);
		}
开发者ID:psni,项目名称:mono,代码行数:20,代码来源:JsonFormatWriterGenerator_static.cs


注:本文中的DataContract类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。