本文整理汇总了C#中SerializationFormat类的典型用法代码示例。如果您正苦于以下问题:C# SerializationFormat类的具体用法?C# SerializationFormat怎么用?C# SerializationFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SerializationFormat类属于命名空间,在下文中一共展示了SerializationFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrent
public static ISerializer GetCurrent(SerializationFormat format)
{
var serializers = Container.GetAll<ISerializer>();
return (from s in serializers
where s.Format == format
select s).FirstOrDefault();
}
示例2: ToClaim
public Claim ToClaim(SerializationFormat serializationFormat = SerializationFormat.Json)
{
return new Claim(ClaimTypes.GroupSid, Sid);
//var serialized = serializationFormat == SerializationFormat.Json
// ? this.ToJson()
// : this.ToXml();
//return new Claim(LDAPClaimTypes.ActiveDirectoryGroup, serialized);
}
示例3: RESTDataClient
/// <summary>
/// Creates a new instance of RESTDataClient.
/// </summary>
/// <param name="serviceUrl">The url endpoint of the service to send data to.</param>
/// <param name="timeout">A timeout for all requests.</param>
/// <param name="compress">Whether to compress data before sending. Only applies when posting JSON or XML, not with HttpQueryString mode.</param>
/// <param name="serializationFormat">The version number to send to the server.</param>
/// <param name="version">The version number to send to the server.</param>
public RESTDataClient(Uri serviceUrl, int timeout, bool compress, SerializationFormat serializationFormat, int version)
{
Version = version;
ServiceUrl = serviceUrl;
Timeout = TimeSpan.FromSeconds(timeout);
Compress = compress;
SerializationFormat = serializationFormat;
AdditionalHttpHeaders = new Dictionary<string, string>();
}
示例4: SerializedValue
public SerializedValue([NotNull] string assemblyQualifiedName)
{
if (assemblyQualifiedName == null)
{
throw new ArgumentNullException("assemblyQualifiedName");
}
_assemblyQualifiedName = assemblyQualifiedName;
_format = SerializationFormat.Null;
}
示例5: HttpCacheRequestHandler
// private SyncReader syncReader;
// private SyncWriter syncWriter;
public HttpCacheRequestHandler(Uri serviceUri, CacheControllerBehavior behaviors)
{
baseUri = serviceUri;
serializationFormat = behaviors.SerializationFormat;
scopeName = behaviors.ScopeName;
credentials = behaviors.Credentials;
knownTypes = new Type[behaviors.KnownTypes.Count];
behaviors.KnownTypes.CopyTo(knownTypes, 0);
scopeParameters = new Dictionary<string, string>(behaviors.ScopeParametersInternal);
}
示例6: JsonResult
public JsonResult(object data, string contentType,
Encoding contentEncoding, SerializationFormat format,
IEnumerable<JavaScriptConverter> converters)
{
_converters = new List<JavaScriptConverter>(
converters ?? Enumerable.Empty<JavaScriptConverter>());
_data = data;
_contentType = contentType;
_contentEncoding = contentEncoding;
_format = format;
}
示例7: HttpCacheRequestHandler
// private SyncReader syncReader;
// private SyncWriter syncWriter;
public HttpCacheRequestHandler(Uri serviceUri, CacheControllerBehavior behaviors)
{
baseUri = serviceUri;
serializationFormat = behaviors.SerializationFormat;
scopeName = behaviors.ScopeName;
credentials = behaviors.Credentials;
knownTypes = new Type[behaviors.KnownTypes.Count];
behaviors.KnownTypes.CopyTo(knownTypes, 0);
scopeParameters = new Dictionary<string, string>(behaviors.ScopeParametersInternal);
customHeaders = new Dictionary<string, string>(behaviors.CustomHeadersInternal);
automaticDecompression = behaviors.AutomaticDecompression;
this.CookieContainer = behaviors.CookieContainer;
}
示例8: Run
public void Run(AmfFile file, out string name, out SerializationFormat format)
{
// Case for "save to file". Fenoxo only serializes ones object and there is no header.
if (_reader.PeekChar() == 0x0A)
{
format = SerializationFormat.Exported;
ReadPlainDataFile(file, out name);
}
// Case for "save to slot". Real AMF3 file with a proper header.
else
{
format = SerializationFormat.Slot;
ReadStandardFile(file, out name);
}
}
示例9: SerializeSystemBoolean
public static Stream SerializeSystemBoolean(bool obj, SerializationFormat serializationFormat, WebMessageFormat webMessageFormat)
{
if (IsXml(serializationFormat, webMessageFormat))
{
var root = new XElement(XName.Get("Boolean"));
var xDocument = new XDocument(root);
root.Add(XmlConvert.ToString(obj));
var stream = GetStream(xDocument);
return stream;
}
else
{
return GetStream(obj.ToJsonString());
}
}
示例10: Get
public ISerializer Get(SerializationFormat format)
{
switch (format)
{
case SerializationFormat.None:
return this.Null;
case SerializationFormat.Json:
return this.Json;
case SerializationFormat.Xml:
return this.Xml;
case SerializationFormat.Binary:
return this.Binary;
case SerializationFormat.Null:
throw new Exception("You must specify a valid SerializationFormat");
default:
throw new Exception(string.Format("There is no serializer with format '{0}'", format));
}
}
示例11: SerializeSystemBooleanArray
public static Stream SerializeSystemBooleanArray(bool[] objs, SerializationFormat serializationFormat, WebMessageFormat webMessageFormat)
{
if (IsXml(serializationFormat, webMessageFormat))
{
var root = new XElement(XName.Get("BooleanArray"));
var xDocument = new XDocument(root);
foreach (var obj in objs)
{
var child = new XElement(XName.Get("Boolean"));
child.Add(XmlConvert.ToString(obj));
}
var stream = GetStream(xDocument);
return stream;
}
else
{
return GetStream(objs.ToJsonString());
}
}
示例12: Run
public void Run(AmfFile file, string newName, SerializationFormat format)
{
switch (format)
{
case SerializationFormat.Slot:
WriteStandardFile(file, newName);
break;
case SerializationFormat.Exported:
WritePlainDataFile(file);
break;
default:
throw new NotImplementedException();
}
// Flush
_writer.Flush();
}
示例13: CacheControllerBehavior
internal CacheControllerBehavior()
{
this._userSession = new SessionInfo();
this._knownTypes = new List<EntityType>();
this._serFormat = SerializationFormat.ODataAtom;
this._scopeParameters = new Dictionary<string, string>();
}
示例14: GenerateReader
//*******************************************************
// Reader generation
//
public void GenerateReader (string readerClassName, ArrayList maps)
{
if (_config == null || !_config.GenerateAsInternal)
WriteLine ("public class " + readerClassName + " : XmlSerializationReader");
else
WriteLine ("internal class " + readerClassName + " : XmlSerializationReader");
WriteLineInd ("{");
// FromBinHexString() is not public, so use reflection here.
WriteLine ("static readonly System.Reflection.MethodInfo fromBinHexStringMethod = typeof (XmlConvert).GetMethod (\"FromBinHexString\", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type [] {typeof (string)}, null);");
WriteLine ("static byte [] FromBinHexString (string input)");
WriteLineInd ("{");
WriteLine ("return input == null ? null : (byte []) fromBinHexStringMethod.Invoke (null, new object [] {input});");
WriteLineUni ("}");
_mapsToGenerate = new ArrayList ();
_fixupCallbacks = new ArrayList ();
InitHooks ();
for (int n=0; n<maps.Count; n++)
{
GenerationResult res = (GenerationResult) maps [n];
_typeMap = res.Mapping;
_format = _typeMap.Format;
_result = res;
GenerateReadRoot ();
}
for (int n=0; n<_mapsToGenerate.Count; n++)
{
XmlTypeMapping map = _mapsToGenerate [n] as XmlTypeMapping;
if (map == null) continue;
GenerateReadObject (map);
if (map.TypeData.SchemaType == SchemaTypes.Enum)
GenerateGetEnumValueMethod (map);
}
GenerateReadInitCallbacks ();
if (_format == SerializationFormat.Encoded)
{
GenerateFixupCallbacks ();
GenerateFillerCallbacks ();
}
WriteLineUni ("}");
UpdateGeneratedTypes (_mapsToGenerate);
}
示例15: CacheRequestHandler
protected CacheRequestHandler(Uri baseUri, SerializationFormat format, string scopeName)
{
this._baseUri = baseUri;
this._serializationFormat = format;
this._scopeName = scopeName;
}