Create() private method

Create a representation of the associated policy-tree that is suitable for serialization
private Create ( string name ) : void
name string
return void
Beispiel #1
0
        /// <summary>
        /// Create a serialization of the current policy object in a stream (e.g. MemoryStream or FileStream)
        /// </summary>
        /// <param name="policyIdentifier"></param>
        /// <param name="format"></param>
        /// <param name="targetStream"></param>
        public void Serialize(string policyIdentifier, PolicySerializationFormat format, Stream targetStream)
        {
            var p = new TpmPolicy(this);

            p.Create(policyIdentifier);

            switch (format)
            {
            case PolicySerializationFormat.Xml:
            {
                var ser = new DataContractSerializer(typeof(TpmPolicy));
                ser.WriteObject(targetStream, p);
                break;
            }

            case PolicySerializationFormat.Json:
            {
                var ser = new DataContractJsonSerializer(typeof(TpmPolicy));
                ser.WriteObject(targetStream, p);
                break;
            }

            default:
                Globs.Throw <ArgumentException>("PolicyTree.Serialize: Unknown format " + format);
                break;
            }
            targetStream.Flush();
        }
Beispiel #2
0
 /// <summary>
 /// Create a serialization of the current policy object in a stream (e.g. MemoryStream or FileStream)
 /// </summary>
 /// <param name="policyIdentifier"></param>
 /// <param name="fileName"></param>
 public void Serialize(string policyIdentifier, PolicySerializationFormat format, Stream targetStream)
 {
     var p = new TpmPolicy(this);
     p.Create(policyIdentifier);
     
     switch(format)
     {
         case PolicySerializationFormat.Xml:
         {
             var ser = new DataContractSerializer(typeof(TpmPolicy));
             ser.WriteObject(targetStream, p);
             break;
         }
         case PolicySerializationFormat.Json:
         {
             var ser = new DataContractJsonSerializer(typeof(TpmPolicy));
             ser.WriteObject(targetStream, p);
             break;
         }
         default:
             Globs.Throw<ArgumentException>("PolicyTree.Serialize: Unknown format " + format);
             break;
     }
     targetStream.Flush();
 }