Пример #1
0
        private T SafeJniCall <T>(Func <T> func)
        {
            GetDelegate <ExceptionClear>(functions.ExceptionClearPtr)(envPtr);
            var result = func();

            return(result);
        }
Пример #2
0
    void OnTriggerEnter(Collider other)
    {
        if (triggerByKeyPress)
        {
            return;
        }

        if (other.tag == Tags.PLAYER)
        {
            GetDelegate(_event)();

            if (ObjectsToActivate.Count > 0)
            {
                foreach (GameObject go in ObjectsToActivate)
                {
                    go.SetActive(activate);
                }
            }

            if (pauseOnTrigger)
            {
                GameManager.Instance.PauseGame(true);
            }

            if (disableOnTrigger)
            {
                gameObject.SetActive(false);
            }
        }
    }
Пример #3
0
        public unsafe void CreateJavaVm(IntPtr *vmP, IntPtr *envP, IntPtr vmArgsP)
        {
            var result = GetDelegate <CreateJavaVm>("JNI_CreateJavaVM")(vmP, envP, vmArgsP);

            if (result != 0)
            {
                throw new InvalidOperationException(string.Format("CreateJavaVM failed - return value obtained: {0}",
                                                                  result));
            }
        }
Пример #4
0
        public string GetAppInstallDir(UInt32 nAppId)
        {
            UInt32 size = 1024;

            byte[] _pchFolder = new byte[size];
            IntPtr pchFolder  = Marshal.AllocHGlobal(_pchFolder.Length + 1);
            UInt32 read       = GetDelegate <GetAppInstallDirDelegate>()(InterfacePtr, nAppId, pchFolder, size);

            return(Encoding.UTF8.GetString(_pchFolder, 0, (int)read));
        }
Пример #5
0
    void OnTriggerStay(Collider other)
    {
        if (!triggerByKeyPress)
        {
            return;
        }

        if (isUIType)
        {
            if (!UIManager.Instance.CanOpenNewUIPanel())
            {
                return;
            }
        }

        if (other.tag == Tags.PLAYER)
        {
            if (Input.GetKeyUp(KeyCode.E))
            {
                GetDelegate(_event)();

                if (GetComponent <DialogSequence>())
                {
                    if (!GetComponent <DialogSequence>().NoLongerTriggerable)
                    {
                        GetComponent <DialogSequence>().InitiateDialog();
                    }
                }

                if (ObjectsToActivate.Count > 0)
                {
                    foreach (GameObject go in ObjectsToActivate)
                    {
                        go.SetActive(activate);
                    }
                }

                if (pauseOnTrigger)
                {
                    GameManager.Instance.PauseGame(true);
                }

                if (disableOnTrigger)
                {
                    gameObject.SetActive(false);
                }

                if (GetComponent <InteractableUI>())
                {
                    UIManager.Instance.DisableInteractionText();
                }
            }
        }
    }
Пример #6
0
        public bool TryCatchEcxeption(out LocalRef ex)
        {
            if (GetDelegate <ExceptionCheck>(functions.ExceptionCheckPtr)(envPtr))
            {
                ex = new LocalRef(GetDelegate <ExceptionOccurred>(functions.ExceptionOccurredPtr)(envPtr));
                return(true);
            }

            ex = null;
            return(false);
        }
Пример #7
0
 public static object DebugRunDelegate(string function, params object[] args)
 {
     try
     {
         return(GetDelegate(function)(args));
     }
     catch (ScriptRuntimeException ex)
     {
         Debug.WriteLine("Doh! An error occured! {0}", ex.DecoratedMessage);
     }
     return(null);
 }
Пример #8
0
        public bool Invalidate(PropertyInfo property, object instance, bool verifyDependance = true)
        {
            object value   = property.GetValue(instance);
            bool   invalid = GetDelegate(property)(value) != Negative;

            if (Dependance != null && verifyDependance)
            {
                bool dependanceInvalid = !ValidationLogic.Validate(property.DeclaringType, Dependance, instance, false);
                return(invalid && dependanceInvalid);
            }
            return(invalid);
        }
    private IEnumerator Polling <T>(string action, GetDelegate <T> onComplete)
    {
        while (true)
        {
            yield return(new WaitForSeconds(pollDelay));

            using (var request = UnityWebRequest.Get(BaseUri + action))
            {
                request.SendWebRequest();

                while (!request.isDone)
                {
                    yield return(null);
                }

                var response = request.downloadHandler.text;
                if (!string.IsNullOrWhiteSpace(response))
                {
                    var dto = JsonUtility.FromJson <T>(response);
                    onComplete(dto);
                    break;
                }
            }
        }
    }
        internal ReflectionProperty(PropertyInfo property)
        {
            this.PropertyInfo = property;
            Attributes        = this.PropertyInfo.GetCustomAttributes(true).OfType <Attribute>().ToList();
            Name         = this.PropertyInfo.Name;
            PropertyType = PropertyInfo.PropertyType;
            if (property.PropertyType.GetTypeInfo().IsGenericType)
            {
                this.GenericTypeDefinition = property.PropertyType.GetGenericTypeDefinition();
                this.GenericTypeArguments  = property.PropertyType.GetGenericArguments();
            }

            var method = this.PropertyInfo.GetGetMethod() ?? this.PropertyInfo.GetGetMethod(true);

            if (method != null)
            {
                HasGet     = true;
                getHandler = DelegateFactory.CreateGet(property);
            }

            method = this.PropertyInfo.GetSetMethod() ?? this.PropertyInfo.GetSetMethod(true);
            if (method != null)
            {
                HasSet     = true;
                setHandler = DelegateFactory.CreateSet(property);
            }
        }
Пример #11
0
        public AccessorBase(Type baseType, FieldInfo field, Processor <TField> processor)
        {
            this.processor = processor;

            var targetExp = Expression.Parameter(typeof(object), "target");

            var valueType = typeof(TField);
            var fieldType = field.FieldType;
            //if (fieldType.IsArray)
            //    fieldType = fieldType.GetElementType();

            var valueExp     = Expression.Parameter(valueType, "value");
            var valueConvExp = (Expression)valueExp;

            if (fieldType != valueType)
            {
                valueConvExp = Expression.Convert(valueExp, fieldType);
            }

            var conversion = Expression.Convert(targetExp, baseType);
            var fieldExp   = Expression.Field(conversion, field);
            var assignExp  = Expression.Assign(fieldExp, valueConvExp);

            var fieldConvExp = (Expression)fieldExp;

            if (fieldType != valueType)
            {
                fieldConvExp = Expression.Convert(fieldExp, valueType);
            }


            getter = Expression.Lambda <GetDelegate <TField> >(fieldConvExp, targetExp).Compile();
            setter = Expression.Lambda <SetDelegate <TField> >(assignExp, targetExp, valueExp).Compile();
        }
Пример #12
0
        /// <summary>
        ///     Iterates a collection, and returns results as nodes back to caller.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="args"></param>
        /// <param name="functor"></param>
        public static void Get (
            ApplicationContext context, 
            Node args, 
            GetDelegate functor)
        {
            // Making sure we clean up and remove all arguments passed in after execution.
            using (var argsRemover = new Utilities.ArgsRemover (args, true)) {

                // Iterating through each key reqquested by caller.
                foreach (var idxKey in Iterate<string> (context, args)) {

                    // Checking if caller tries to access "protected storage key", which we do not allow, unless this is a native invocation, signified by that the caller invoked
                    // us with a "." as the name of the node.
                    if (!args.Name.StartsWith (".") && (idxKey.StartsWith ("_") || idxKey.StartsWith (".")))
                        throw new LambdaException (
                            string.Format ("Tried to access protected key in [{0}], key name was '{1}' ", args.Name, idxKey), 
                            args, 
                            context);

                    // Retrieving object by invoking delegate functor with key, and returning as child of args, if there is a value.
                    var value = functor (idxKey);
                    if (value != null) {

                        // Checking type of value, and acting accordingly.
                        if (value is Node)
                            args.Add (idxKey, null, (value as Node).Clone ());
                        else
                            args.Add (idxKey, value);
                    }
                }
            }
        }
Пример #13
0
 public void AddInfo(TextBox txtBox, ListBox listBox, AddDelegate addMethod, GetDelegate getMethod)
 {
     string txt = txtBox.Text;
     int addCount = 0;
     DataSet ds;
     if (txt != "")
     {
         addCount = addMethod(txt);
         if (addCount <= 0)
         {
             MsgBox("该值已存在!");
         }
     }
     else
     {
         MsgBox("不能添加空值!");
     }
     listBox.Items.Clear();
     txtBox.Text = "";
     ds = getMethod();
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         listBox.Items.Add(ds.Tables[0].Rows[i][0].ToString());
     }
     txtBox.Focus();
 }
Пример #14
0
        public static GetDelegate GetGetMethodByExpression(FieldInfo fieldInfo)
        {
            ParameterExpression instance = Expression.Parameter(typeof(object), "instance");
            MemberExpression    member   = Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo);
            GetDelegate         compiled = Expression.Lambda <GetDelegate>(Expression.Convert(member, typeof(object)), instance).Compile();

            return(delegate(object source) { return compiled(source); });
        }
Пример #15
0
 public void BindData(GetDelegate getMethod, DropDownList ddl)
 {
     DataSet ds = getMethod();
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         ddl.Items.Add(ds.Tables[0].Rows[i][0].ToString());
     }
 }
Пример #16
0
 internal static void Bind()
 {
     _closeDelegate = Library.GetProcAddress <CloseDelegate>("mdbx_cursor_close") as CloseDelegate;
     _openDelegate  = Library.GetProcAddress <OpenDelegate>("mdbx_cursor_open") as OpenDelegate;
     _getDelegate   = Library.GetProcAddress <GetDelegate>("mdbx_cursor_get") as GetDelegate;
     _putDelegate   = Library.GetProcAddress <PutDelegate>("mdbx_cursor_put") as PutDelegate;
     _delDelegate   = Library.GetProcAddress <DelDelegate>("mdbx_cursor_del") as DelDelegate;
     _countDelegate = Library.GetProcAddress <CountDelegate>("mdbx_cursor_count") as CountDelegate;
 }
Пример #17
0
        public static GetDelegate GetGetMethodByExpression(FieldInfo fieldInfo)
        {
            ParameterExpression expression = Expression.Parameter(typeof(object), "instance");

            ParameterExpression[] parameters = new ParameterExpression[] { expression };
            GetDelegate           compiled   = Expression.Lambda <GetDelegate>(Expression.Convert(Expression.Field(Expression.Convert(expression, fieldInfo.DeclaringType), fieldInfo), typeof(object)), parameters).Compile();

            return(source => compiled(source));
        }
Пример #18
0
 internal static void Bind()
 {
     _openDelegate  = Library.GetProcAddress <OpenDelegate>("mdbx_dbi_open") as OpenDelegate;
     _closeDelegate = Library.GetProcAddress <CloseDelegate>("mdbx_dbi_close") as CloseDelegate;
     _putDelegate   = Library.GetProcAddress <PutDelegate>("mdbx_put") as PutDelegate;
     _getDelegate   = Library.GetProcAddress <GetDelegate>("mdbx_get") as GetDelegate;
     _delDelegate   = Library.GetProcAddress <DelDelegate>("mdbx_del") as DelDelegate;
     _dropDelegate  = Library.GetProcAddress <DropDelegate>("mdbx_drop") as DropDelegate;
 }
Пример #19
0
 public Connection(string user, IPAddress userip, GetDelegate getDel, DisplayDelegate displayDel, ClearScreen ClearScreen)
 {
     userName = user;
     userIP   = userip;
     get      = getDel;
     display  = displayDel;
     history  = new StringBuilder();
     synchronizationContext = SynchronizationContext.Current;
     clearScreen            = ClearScreen;
 }
Пример #20
0
        public static GetDelegate GetGetMethodByExpression(FieldInfo fieldInfo)
        {
            ParameterExpression parameterExpression = Expression.Parameter(typeof(object), "instance");
            MemberExpression    expression          = Expression.Field(Expression.Convert(parameterExpression, fieldInfo.DeclaringType), fieldInfo);
            GetDelegate         compiled            = Expression.Lambda <GetDelegate>(Expression.Convert(expression, typeof(object)), new ParameterExpression[1]
            {
                parameterExpression
            }).Compile();

            return((object source) => compiled(source));
        }
Пример #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomValueContainer"/> class.
        /// </summary>
        /// <param name="valueType">Type of the value.</param>
        /// <param name="getter">The value getter.</param>
        /// <param name="setter">The value setter.</param>
        public CustomValueContainer(Type valueType, GetDelegate getter, SetDelegate setter)
            : base(null, valueType)
        {
            if (getter == null || setter == null)
            {
                throw new ArgumentNullException();
            }

            _getter = getter;
            _setter = setter;
        }
Пример #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomValueContainer"/> class.
        /// </summary>
        /// <param name="valueType">Type of the value.</param>
        /// <param name="getter">The value getter.</param>
        /// <param name="setter">The value setter.</param>
        /// <param name="attributes">The custom type attributes used to override the value editor logic or appearance (eg. instance of <see cref="LimitAttribute"/>).</param>
        public CustomValueContainer(ScriptType valueType, GetDelegate getter, SetDelegate setter, object[] attributes = null)
            : base(ScriptMemberInfo.Null, valueType)
        {
            if (getter == null || setter == null)
            {
                throw new ArgumentNullException();
            }

            _getter     = getter;
            _setter     = setter;
            _attributes = attributes;
        }
Пример #23
0
 public C Get()
 {
     if (_c.InvokeRequired)
     {
         GetDelegate <C> d = new GetDelegate <C>(Get);
         return((C)_f.Invoke(d));
     }
     else
     {
         return(_c);
     }
 }
    IEnumerator WinAnimation(bool guardsOrSpies)
    {
        SetActive(true);
        _winText.gameObject.SetActive(true);
        _starSprite.gameObject.SetActive(true);
        RectTransform winnerTrans = _guardSprite.rectTransform;

        if (guardsOrSpies)
        {
            _guardSprite.gameObject.SetActive(true);
            _spySprite.gameObject.SetActive(false);
            _winText.text = "Guards\nWin!";
        }
        else
        {
            winnerTrans = _spySprite.rectTransform;
            _spySprite.gameObject.SetActive(true);
            _guardSprite.gameObject.SetActive(false);
            _winText.text = "Spies\nWin!";
        }

        StartCoroutine(FadeOutBackground(1));

        // Initialize positions
        Vector2       initialPos = winnerTrans.localPosition;
        RectTransform starTrans  = _starSprite.rectTransform;
        Vector2       starSize   = starTrans.sizeDelta;

        starTrans.sizeDelta       = new Vector2(0, 0);
        winnerTrans.localPosition = new Vector2(0, Screen.height / 2 + winnerTrans.sizeDelta.y / 2.0f);

        // Smoothly animate drop down for winnerTrans
        GetDelegate <Vector2> getter = () => { return(winnerTrans.localPosition); };
        SetDelegate <Vector2> setter = v => { winnerTrans.localPosition = v; };

        yield return(StartCoroutine(SmoothVector2Lerp(getter, setter, winnerTrans.localPosition, initialPos, 2.0f)));

        // Spin the star simultaneously
        StartCoroutine(SpinStar(20.0f));

        // Smoothly animate star reveal
        getter = () => { return(starTrans.sizeDelta); };
        setter = v => { starTrans.sizeDelta = v; };
        yield return(StartCoroutine(SmoothVector2Lerp(getter, setter, starTrans.sizeDelta, starSize, 4.0f)));

        // Reveal Win Text
        yield return(StartCoroutine(RevealWinText(1)));

        StartCoroutine(LeaveRoom());
        yield return(null);
    }
    private IEnumerator Getting <T>(string action, GetDelegate <T> onComplete)
    {
        using (var request = UnityWebRequest.Get(BaseUri + action))
        {
            request.SendWebRequest();
            while (!request.isDone)
            {
                yield return(null);
            }

            var response = JsonUtility.FromJson <T>(request.downloadHandler.text);
            onComplete(response);
        }
    }
Пример #26
0
 //2、定义委托调用的方法
 static void MySort(string[] arr, GetDelegate getDelegate)
 {
     for (int i = 0; i < arr.Length - 1; i++)
     {
         for (int j = 0; j < arr.Length - 1 - i; j++)
         {
             //调用方法
             if (getDelegate(arr[j], arr[j + 1]) > 0)
             {
                 string t = arr[j];
                 arr[j]     = arr[j + 1];
                 arr[j + 1] = t;
             }
         }
     }
 }
Пример #27
0
        // *************** Asynchronous Get ***************************
        public static void RestGetAsync <TR>(string url, RestCallBack <TR> callback,
                                             ClientConfiguration configuration)
        {
            var get = new GetDelegate <TR>(RestGet <TR>);

            get.BeginInvoke(url, configuration,
                            ar =>
            {
                var result  = (AsyncResult)ar;
                var del     = (GetDelegate <TR>)result.AsyncDelegate;
                var value   = default(TR);
                Exception e = null;

                try { value = del.EndInvoke(result); }
                catch (Exception ex) { e = ex; }

                callback?.Invoke(e, value);
            }, null);
        }
Пример #28
0
        public void DelInfo(ListBox listBox, AddDelegate delMethod, GetDelegate getMethod)
        {
            ListItem delName = listBox.SelectedItem;
            DataSet ds;

            if (delName == null)
            {
                MsgBox("请选择要删除的项!");
            }
            else
            {
                delMethod(delName.Text);
            }

            listBox.Items.Clear();
            ds = getMethod();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                listBox.Items.Add(ds.Tables[0].Rows[i][0].ToString());
            }
        }
        /// <summary>
        /// Create a connection to a Snowplow collector
        /// <param name="host">The hostname of the collector (not including the scheme, e.g. http://)</param>
        /// <param name="protocol">The protocol to use. HTTP or HTTPS</param>
        /// <param name="port">The port number the collector is listening on</param>
        /// <param name="method">The request method to use. GET or POST</param>
        /// <param name="postMethod">Internal use</param>
        /// <param name="getMethod">Internal use</param>
        /// <param name="byteLimitPost">The maximum amount of bytes we can expect to work</param>
        /// <param name="byteLimitGet">The maximum amount of bytes we can expect to work</param>
        /// <param name="l">Send log messages using this logger</param>
        /// </summary>
        public SnowplowHttpCollectorEndpoint(string host, HttpProtocol protocol = HttpProtocol.HTTP, int?port = null, HttpMethod method = HttpMethod.GET,
                                             PostDelegate postMethod            = null, GetDelegate getMethod = null, int byteLimitPost = 40000, int byteLimitGet = 40000, ILogger l = null)
        {
            if (Uri.IsWellFormedUriString(host, UriKind.Absolute))
            {
                var uri = new Uri(host);
                var endpointWithoutScheme = uri.Host;
                _collectorUri = getCollectorUri(endpointWithoutScheme, protocol, port, method);
            }
            else
            {
                _collectorUri = getCollectorUri(host, protocol, port, method);
            }

            _method        = method;
            _postMethod    = postMethod ?? DefaultPostMethod;
            _getMethod     = getMethod ?? DefaultGetMethod;
            _byteLimitPost = byteLimitPost;
            _byteLimitGet  = byteLimitGet;
            _logger        = l ?? new NoLogging();
        }
 public void LoadFromISource(ISource Source, GetDelegate Book_Func, GetDelegate Visitor_Func)
 {
     ThrowString(Source.Ready ? "Источник готов" : "Источник не готов.");
     if (Source.Ready)
     {
         foreach (ISource.Book Book in Source.Books)
         {
             Books.Add(new LibraryModel.BookModel(Book.Id, Book.Title, Book.Author, Book_Func()));
         }
         foreach (ISource.Visitor Visitor in Source.Visitors)
         {
             Visitors.Add(new LibraryModel.VisitorModel(Visitor.Id, Visitor.Name, Visitor_Func()));
         }
         foreach (ISource.Issue Issue in Source.Issues)
         {
             var Book = Books[Books.FindIndex(x => x.GetId() == Issue.Book_Id)];
             // Выдать на один месяц
             Book.Issue(Issue.Issue_Date, Issue.Issue_Date.AddMonths(1));
             Books[Books.FindIndex(x => x.GetId() == Issue.Book_Id)] = Book;
             Visitors[Visitors.FindIndex(x => x.GetId() == Issue.Visitor_Id)].GiveBook(Book);
         }
     }
 }
    IEnumerator SmoothVector2Lerp(GetDelegate <Vector2> getter, SetDelegate <Vector2> setter, Vector2 initial, Vector2 final, float speed)
    {
        setter(initial);
        Vector2 yVelocity = final - initial;
        float   magnitude = yVelocity.magnitude;

        yVelocity = yVelocity.normalized;
        Vector2 overShotFinal = final + (yVelocity * magnitude * 0.1f);

        while (true)
        {
            Vector2 newVec         = Vector2.Lerp(getter(), overShotFinal, Time.deltaTime * speed);
            Vector2 checkDireciton = (final - newVec).normalized;
            if (checkDireciton != yVelocity)
            {
                newVec = final;
                setter(newVec);
                break;
            }
            setter(newVec);
            yield return(new WaitForEndOfFrame());
        }
        yield return(null);
    }
Пример #32
0
        // Запуск сервера
        public static void Run(int Port, GetDelegate _GetDelegate)
        {
            Listener = new TcpListener(IPAddress.Any, Port); // Создаем "слушателя" для указанного порта
            Listener.Start(); // Запускаем его

            BGW = new BackgroundWorker();
            BGW.WorkerSupportsCancellation = true;
            BGW.DoWork +=
                (o, e) =>
                {
                    while (!((BackgroundWorker)o).CancellationPending)
                    {
                        try
                        {
                            if (Listener != null)
                            {
                                // Принимаем новых клиентов. После того, как клиент был принят, он передается в новый поток (ClientThread)
                                // с использованием пула потоков.
                                List<object> par = new List<object>();
                                par.Add(Listener.AcceptTcpClient());
                                par.Add(_GetDelegate);
                                // Создаем поток
                                Thread Thread = new Thread(new ParameterizedThreadStart(ClientThread));
                                // И запускаем этот поток, передавая ему принятого клиента
                                Thread.Start(par);
                            }
                        }
                        catch { }
                    }
                };
            BGW.RunWorkerCompleted += (obj, args) =>
            {
                BGW = null;
            };
            BGW.RunWorkerAsync();
        }
        public MovieAwardsWon GetMovieAwardsWon(string email)
        {
            var d = new GetDelegate(email);

            return(executor.ExecuteReader(d));
        }
Пример #34
0
        public Oscars GetOscars(int Year)
        {
            var d = new GetDelegate(Year);

            return(executor.ExecuteReader(d));
        }
Пример #35
0
        /// <summary>
        /// Select the appropriate conversion routine for packed data.
        /// </summary>
        private bool pickContigCase()
        {
            get = tif.IsTiled() ? new GetDelegate(gtTileContig) : new GetDelegate(gtStripContig);
            putContig = null;

            switch (photometric)
            {
                case Photometric.RGB:
                    switch (bitspersample)
                    {
                        case 8:
                            if (alpha == ExtraSample.AssociatedAlpha)
                                putContig = putRGBAAcontig8bittile;
                            else if (alpha == ExtraSample.UnAssociatedAlpha)
                                putContig = putRGBUAcontig8bittile;
                            else
                                putContig = putRGBcontig8bittile;
                            break;

                        case 16:
                            if (alpha == ExtraSample.AssociatedAlpha)
                                putContig = putRGBAAcontig16bittile;
                            else if (alpha == ExtraSample.UnAssociatedAlpha)
                                putContig = putRGBUAcontig16bittile;
                            else
                                putContig = putRGBcontig16bittile;
                            break;
                    }
                    break;

                case Photometric.Separated:
                    if (buildMap())
                    {
                        if (bitspersample == 8)
                        {
                            if (Map == null)
                                putContig = putRGBcontig8bitCMYKtile;
                            else
                                putContig = putRGBcontig8bitCMYKMaptile;
                        }
                    }
                    break;

                case Photometric.Palette:
                    if (buildMap())
                    {
                        switch (bitspersample)
                        {
                            case 8:
                                putContig = put8bitcmaptile;
                                break;
                            case 4:
                                putContig = put4bitcmaptile;
                                break;
                            case 2:
                                putContig = put2bitcmaptile;
                                break;
                            case 1:
                                putContig = put1bitcmaptile;
                                break;
                        }
                    }
                    break;

                case Photometric.MinIsWhite:
                case Photometric.MinIsBlack:
                    if (buildMap())
                    {
                        switch (bitspersample)
                        {
                            case 16:
                                putContig = put16bitbwtile;
                                break;
                            case 8:
                                putContig = putgreytile;
                                break;
                            case 4:
                                putContig = put4bitbwtile;
                                break;
                            case 2:
                                putContig = put2bitbwtile;
                                break;
                            case 1:
                                putContig = put1bitbwtile;
                                break;
                        }
                    }
                    break;

                case Photometric.YCBCR:
                    if (bitspersample == 8)
                    {
                        if (initYCbCrConversion())
                        {
                            // The 6.0 spec says that subsampling must be one of 1, 2, or 4, and
                            // that vertical subsampling must always be <= horizontal subsampling;
                            // so there are only a few possibilities and we just enumerate the cases.
                            // Joris: added support for the [1, 2] case, nonetheless, to accommodate
                            // some OJPEG files
                            FieldValue[] result = tif.GetFieldDefaulted(TiffTag.YCBCRSUBSAMPLING);
                            short SubsamplingHor = result[0].ToShort();
                            short SubsamplingVer = result[1].ToShort();

                            switch (((ushort)SubsamplingHor << 4) | (ushort)SubsamplingVer)
                            {
                                case 0x44:
                                    putContig = putcontig8bitYCbCr44tile;
                                    break;
                                case 0x42:
                                    putContig = putcontig8bitYCbCr42tile;
                                    break;
                                case 0x41:
                                    putContig = putcontig8bitYCbCr41tile;
                                    break;
                                case 0x22:
                                    putContig = putcontig8bitYCbCr22tile;
                                    break;
                                case 0x21:
                                    putContig = putcontig8bitYCbCr21tile;
                                    break;
                                case 0x12:
                                    putContig = putcontig8bitYCbCr12tile;
                                    break;
                                case 0x11:
                                    putContig = putcontig8bitYCbCr11tile;
                                    break;
                            }
                        }
                    }
                    break;

                case Photometric.CIELAB:
                    if (buildMap())
                    {
                        if (bitspersample == 8)
                            putContig = initCIELabConversion();
                    }
                    break;
            }

            return (putContig != null);
        }
Пример #36
0
 static CurrentTimeGetter()
 {
     // this is to keep Mono compiler quiet
     _getDelegate = new GetDelegate(NonOptimizedGet);
     _getDelegate = new GetDelegate(ThrottledGet);
 }
Пример #37
0
        /// <summary>
        /// Select the appropriate conversion routine for unpacked data.
        /// NB: we assume that unpacked single channel data is directed to the "packed routines.
        /// </summary>
        private bool pickSeparateCase()
        {
            get = tif.IsTiled() ? new GetDelegate(gtTileSeparate) : new GetDelegate(gtStripSeparate);
            putSeparate = null;

            switch (photometric)
            {
                case Photometric.RGB:
                    switch (bitspersample)
                    {
                        case 8:
                            if (alpha == ExtraSample.AssociatedAlpha)
                                putSeparate = putRGBAAseparate8bittile;
                            else if (alpha == ExtraSample.UnAssociatedAlpha)
                                putSeparate = putRGBUAseparate8bittile;
                            else
                                putSeparate = putRGBseparate8bittile;
                            break;

                        case 16:
                            if (alpha == ExtraSample.AssociatedAlpha)
                                putSeparate = putRGBAAseparate16bittile;
                            else if (alpha == ExtraSample.UnAssociatedAlpha)
                                putSeparate = putRGBUAseparate16bittile;
                            else
                                putSeparate = putRGBseparate16bittile;
                            break;
                    }
                    break;

                case Photometric.YCBCR:
                    if ((bitspersample == 8) && (samplesperpixel == 3))
                    {
                        if (initYCbCrConversion())
                        {
                            FieldValue[] result = tif.GetFieldDefaulted(TiffTag.YCBCRSUBSAMPLING);
                            short hs = result[0].ToShort();
                            short vs = result[0].ToShort();

                            switch (((ushort)hs << 4) | (ushort)vs)
                            {
                                case 0x11:
                                    putSeparate = putseparate8bitYCbCr11tile;
                                    break;
                                // TODO: add other cases here
                            }
                        }
                    }
                    break;
            }

            return (putSeparate != null);
        }
Пример #38
0
		/// <param name="getter"></param>
		/// <param name="setter"> if null, Variable is readonly. </param>
		public VariableFunc(GetDelegate getter, SetDelegate setter)
		{
			get = getter;
			set = setter;
			Readonly = set == null;
		}