本文整理汇总了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;
}
}
示例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>() };
}
示例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;
}
}
示例4: XmlObjectSerializerWriteContextComplexJson
public XmlObjectSerializerWriteContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract)
: base(null, int.MaxValue, new StreamingContext(), true)
{
_jsonSerializer = serializer;
this.rootTypeDataContract = rootTypeDataContract;
this.serializerKnownTypeList = serializer.knownTypeList;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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);
}