コード例 #1
0
 private static byte[] AddModeToData(byte[] data, StorageModes mode)
 {
     var output = new byte[data.Length + 1];
     output[data.Length] = (byte)mode;
     data.CopyTo(output, 0);
     return output;
 }
コード例 #2
0
 internal static MvcHtmlString Create(string key, object model, StorageModes mode)
 {
     var tagBuilder = new TagBuilder("input");
     tagBuilder.Attributes["type"] = "hidden";
     tagBuilder.Attributes["name"] = key;
     tagBuilder.Attributes["value"] = Serialization.ModelData.Serialize(model, mode);
     return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.SelfClosing));
 }
コード例 #3
0
        private static byte[] AddModeToData(byte[] data, StorageModes mode)
        {
            var output = new byte[data.Length + 1];

            output[data.Length] = (byte)mode;
            data.CopyTo(output, 0);
            return(output);
        }
コード例 #4
0
        internal static MvcHtmlString Create(string key, object model, StorageModes mode)
        {
            var tagBuilder = new TagBuilder("input");

            tagBuilder.Attributes["type"]  = "hidden";
            tagBuilder.Attributes["name"]  = key;
            tagBuilder.Attributes["value"] = Serialization.ModelData.Serialize(model, mode);
            return(MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.SelfClosing)));
        }
コード例 #5
0
 internal static DataWithArchivingInfo FromUnprocessedData(byte[] data, StorageModes mode)
 {
     return new DataWithArchivingInfo()
     {
         IsEncrypted = false,
         Data = AddModeToData(data, mode),
         Mode = mode
     };
 }
コード例 #6
0
 internal static DataWithArchivingInfo FromUnprocessedData(byte[] data, StorageModes mode)
 {
     return(new DataWithArchivingInfo()
     {
         IsEncrypted = false,
         Data = AddModeToData(data, mode),
         Mode = mode
     });
 }
コード例 #7
0
ファイル: ThumbnailProviderBase.cs プロジェクト: mveril/mmsf
        void IInitializeWithStream.Initialize(IStream stream, StorageModes storageMode)
        {
            Debug.WriteLine("[{0}] ThumbnailProviderBase.IInitializeWithStream.Initialize, mode={1})", Id, storageMode);

            if (initialized)
            {
                throw new COMException("Already initialized", HResults.ErrorAlreadyInitialized);
            }

            comStream   = new ComStream(stream);
            initialized = true;
        }
コード例 #8
0
        public PackedSparseMatrix(SymmetricSparseMatrix m, bool bTranspose = false)
        {
            int numRows = (bTranspose) ? m.Columns : m.Rows;

            Columns = (bTranspose) ? m.Columns : m.Rows;

            Rows = new nonzero[numRows][];

            int[] counts = new int[numRows];
            foreach (Index2i ij in m.NonZeroIndices())
            {
                counts[ij.a]++;
                if (ij.a != ij.b)
                {
                    counts[ij.b]++;
                }
            }

            NumNonZeros = 0;
            for (int k = 0; k < numRows; ++k)
            {
                Rows[k]      = new nonzero[counts[k]];
                NumNonZeros += counts[k];
            }


            int[] accum = new int[numRows];
            foreach (KeyValuePair <Index2i, double> ijv in m.NonZeros())
            {
                int i = ijv.Key.a, j = ijv.Key.b;
                if (bTranspose)
                {
                    int tmp = i; i = j; j = tmp;
                }

                int k = accum[i]++;
                Rows[i][k].j = j; Rows[i][k].d = ijv.Value;

                if (i != j)
                {
                    k            = accum[j]++;
                    Rows[j][k].j = i; Rows[j][k].d = ijv.Value;
                }
            }

            //for (int k = 0; k < numRows; ++k)
            //    Debug.Assert(accum[k] == counts[k]);

            Sorted      = false;
            IsSymmetric = true;
            StorageMode = StorageModes.Full;
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Configuration"/> class.
 /// </summary>
 /// <param name="storageMode">The storage mode.</param>
 /// <param name="encryptionKey">The encryption key.</param>
 /// <param name="encryptionIV">The encryption IV.</param>
 public Configuration(StorageModes storageMode, byte[] encryptionKey, byte[] encryptionIV)
 {
     this.StorageMode = storageMode;
     if ((encryptionKey != null) || (encryptionIV != null))
     {
         this.EncryptionKey = encryptionKey;
         this.EncryptionIV  = encryptionIV;
     }
     else
     {
         SetDefaultEncryptionSettings();
     }
 }
コード例 #10
0
ファイル: InfoTipBase.cs プロジェクト: vbaderks/mmsf
        void IInitializeWithStream.Initialize(IStream stream, StorageModes storageMode)
        {
            Debug.WriteLine("[{0}] InfoTipBase.IInitializeWithStream.Initialize, mode={1})", Id, storageMode);

            if (initialized)
            {
                throw new COMException("Already initialized", HResults.ErrorAlreadyInitialized);
            }

            using (var comStream = new ComStream(stream))
            {
                InitializeCore(comStream);
                initialized = true;
            }
        }
コード例 #11
0
        public PackedSparseMatrix(PackedSparseMatrix copy)
        {
            int N = copy.Rows.Length;

            Rows = new nonzero[N][];
            for (int r = 0; r < N; ++r)
            {
                Rows[r] = new nonzero[copy.Rows[r].Length];
                Array.Copy(copy.Rows[r], Rows[r], Rows[r].Length);
            }
            Columns     = copy.Columns;
            Sorted      = copy.Sorted;
            NumNonZeros = copy.NumNonZeros;
            StorageMode = copy.StorageMode;
            IsSymmetric = copy.IsSymmetric;
        }
コード例 #12
0
        public PackedSparseMatrix(DVector <matrix_entry> entries, int numRows, int numCols, bool bSymmetric = true)
        {
            Columns = numCols;
            Rows    = new nonzero[numRows][];

            int N = entries.size;

            int[] counts = new int[numRows];
            for (int i = 0; i < N; ++i)
            {
                counts[entries[i].r]++;
                if (bSymmetric && entries[i].r != entries[i].c)
                {
                    counts[entries[i].c]++;
                }
            }

            NumNonZeros = 0;
            for (int k = 0; k < numRows; ++k)
            {
                Rows[k]      = new nonzero[counts[k]];
                NumNonZeros += counts[k];
            }

            int[] accum = new int[numRows];
            for (int i = 0; i < N; ++i)
            {
                matrix_entry e = entries[i];
                int          k = accum[e.r]++;
                Rows[e.r][k].j = e.c;
                Rows[e.r][k].d = e.value;

                if (bSymmetric && e.c != e.r)
                {
                    k = accum[e.c]++;
                    Rows[e.c][k].j = e.r;
                    Rows[e.c][k].d = e.value;
                }
            }

            //for (int k = 0; k < numRows; ++k)
            //    Debug.Assert(accum[k] == counts[k]);

            Sorted      = false;
            IsSymmetric = bSymmetric;
            StorageMode = StorageModes.Full;
        }
コード例 #13
0
 internal static string Archive(string text, StorageModes mode)
 {
     var data = Encoding.UTF8.GetBytes(text);
     byte[] archivedData = null;
     switch (mode)
     {
         case StorageModes.CompressAndEncrypt:
             archivedData = AesEncryption.Encrypt(DeflateCompression.Compress(data));
             break;
         case StorageModes.Compress:
             archivedData = DeflateCompression.Compress(data);
             break;
         case StorageModes.Store:
             archivedData = data;
             break;
     }
     var dataWithEncryptionInfo = DataWithArchivingInfo.FromUnprocessedData(archivedData, mode);
     return Convert.ToBase64String(dataWithEncryptionInfo.Data);
 }
コード例 #14
0
        internal static string Archive(string text, StorageModes mode)
        {
            var data = Encoding.UTF8.GetBytes(text);

            byte[] archivedData = null;
            switch (mode)
            {
            case StorageModes.CompressAndEncrypt:
                archivedData = AesEncryption.Encrypt(DeflateCompression.Compress(data));
                break;

            case StorageModes.Compress:
                archivedData = DeflateCompression.Compress(data);
                break;

            case StorageModes.Store:
                archivedData = data;
                break;
            }
            var dataWithEncryptionInfo = DataWithArchivingInfo.FromUnprocessedData(archivedData, mode);

            return(Convert.ToBase64String(dataWithEncryptionInfo.Data));
        }
コード例 #15
0
ファイル: ThumbnailProviderBase.cs プロジェクト: mveril/mmsf
 void IInitializeWithFile.Initialize(string filePath, StorageModes storageMode)
 {
     throw new NotImplementedException();
 }
コード例 #16
0
 public void Initialize(IStream stream, StorageModes storageMode)
 {
     Contract.Requires(stream != null);
 }
 /// <summary>
 /// Serialize the model for persisting between roundtrips.
 /// Use either a <see cref="RoundTripModelAttribute"/> on the model parameter posted to a controller action, or on of the controller extensions, to get the data back.
 /// The <see cref="RoundTripModelAttribute"/> merges the original model with the posted values, so it is ready for use.
 /// The controller extensions gets an object with the original data, and does not merge with posted values.
 /// </summary>
 /// <param name="htmlHelper">The HTML.</param>
 /// <param name="key">The target key for the data. (For special cases with multiple instances)</param>
 /// <param name="model">The model to serialize.</param>
 /// <param name="mode">The storage mode.</param>
 /// <returns>
 /// Returns a <see cref="MvcHtmlString"/> containing a hidden input field.
 /// </returns>
 public static MvcHtmlString RoundTripModelFor(this HtmlHelper htmlHelper, string key, object model, StorageModes mode)
 {
     return(Controls.SerializedModel.Create(key, model, mode));
 }
コード例 #18
0
 internal static MvcHtmlString Create(object model, StorageModes mode)
 {
     return(Create(TypeManagement.TypeManager.GetTypeId(model.GetType()), model, mode));
 }
 /// <summary>
 /// Serialize the model for persisting between roundtrips.
 /// Use either a <see cref="RoundTripModelAttribute"/> on the model parameter posted to a controller action, or on of the controller extensions, to get the data back.
 /// The <see cref="RoundTripModelAttribute"/> merges the original model with the posted values, so it is ready for use.
 /// The controller extensions gets an object with the original data, and does not merge with posted values.
 /// </summary>
 /// <typeparam name="TModel">The type of the model.</typeparam>
 /// <typeparam name="TProperty">The type of the property.</typeparam>
 /// <param name="htmlHelper">The HtmlHelper.</param>
 /// <param name="expression">The expression.</param>
 /// <param name="mode">The storage mode.</param>
 /// <returns>
 /// Returns a <see cref="MvcHtmlString"/> containing a hidden input field.
 /// </returns>
 public static MvcHtmlString RoundTripModelFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, StorageModes mode)
 {
     return(RoundTripModelFor(htmlHelper, Utilities.ExpressionTools.GetElementNameFromModel(htmlHelper.ViewData, expression), ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).Model, mode));
 }
コード例 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Configuration"/> class.
 /// </summary>
 /// <param name="storageMode">The storage mode.</param>
 public Configuration(StorageModes storageMode)
     : this(storageMode, null, null)
 {
 }
コード例 #21
0
 internal static MvcHtmlString Create(object model, StorageModes mode)
 {
     return Create(TypeManagement.TypeManager.GetTypeId(model.GetType()), model, mode);
 }
コード例 #22
0
 private FormWrapper(System.Web.Mvc.Html.MvcForm form, ViewContext viewContext, StorageModes mode)
 {
     this.Form        = form;
     this.viewContext = viewContext;
     viewContext.Writer.WriteLine(SerializedModel.Create(viewContext.ViewData.Model, mode));
 }
コード例 #23
0
 internal static FormWrapper Create(System.Web.Mvc.Html.MvcForm form, ViewContext viewContext, StorageModes mode)
 {
     return new FormWrapper(form, viewContext, mode);
 }
コード例 #24
0
 private FormWrapper(System.Web.Mvc.Html.MvcForm form, ViewContext viewContext, StorageModes mode)
 {
     this.Form = form;
     this.viewContext = viewContext;
     viewContext.Writer.WriteLine(SerializedModel.Create(viewContext.ViewData.Model, mode));
 }
コード例 #25
0
 internal static FormWrapper Create(System.Web.Mvc.Html.MvcForm form, ViewContext viewContext, StorageModes mode)
 {
     return(new FormWrapper(form, viewContext, mode));
 }
コード例 #26
0
 /// <summary>
 /// Serialize the model for persisting between roundtrips.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="mode">The storage mode.</param>
 /// <returns>
 /// Returns a string with the serialized data.
 /// </returns>
 public static string Serialize(object model, StorageModes mode)
 {
     return(Archiving.Archiver.Archive(Serializer.Serialize(model), mode));
 }