text:
namespace Envoy {
namespace Filter {

TcpProxyConfig::Route::Route(const Json::Object& config) {
  cluster_name_ = config.getString("cluster");

  if (config.hasObject("source_ip_list")) {
    source_ips_ = Network::Address::IpList(config.getStringArray("source_ip_list"));
  }

  if (config.hasObject("source_ports")) {
    const std::string source_ports = config.getString("source_ports");
    Network::Utility::parsePortRangeList(source_ports, source_port_ranges_);
  }

  if (config.hasObject("destination_ip_list")) {
    destination_ips_ = Network::Address::IpList(config.getStringArray("destination_ip_list"));
  }

  if (config.hasObject("destination_ports")) {
    const std::string destination_ports = config.getString("destination_ports");
    Network::Utility::parsePortRangeList(destination_ports, destination_port_ranges_);
  }
}

TcpProxyConfig::TcpProxyConfig(const Json::Object& config,
                               Upstream::ClusterManager& cluster_manager, Stats::Scope& scope)
    : stats_(generateStats(config.getString("stat_prefix"), scope)) {
  config.validateSchema(Json::Schema::TCP_PROXY_NETWORK_FILTER_SCHEMA);

  for (const Json::ObjectSharedPtr& route_desc :
       config.getObject("route_config")->getObjectArray("routes")) {
    routes_.emplace_back(Route(*route_desc));

    if (!cluster_manager.get(route_desc->getString("cluster"))) {
      throw EnvoyException(fmt::format("tcp proxy: unknown cluster '{}' in TCP route",
                                       route_desc->getString("cluster")));
    }
  }
}

const std::string& TcpProxyConfig::getRouteFromEntries(Network::Connection& connection) {
  for (const TcpProxyConfig::Route& route : routes_) {
    if (!route.source_port_ranges_.empty() &&
        !Network::Utility::portInRangeList(connection.remoteAddress(), route.source_port_ranges_)) {
      continue;
    }

    if (!route.source_ips_.empty() && !route.source_ips_.contains(connection.remoteAddress())) {
      continue;
    }

    if (!route.destination_port_ranges_.empty() &&
        !Network::Utility::portInRangeList(connection.localAddress(),
                                           route.destination_port_ranges_)) {
      continue;
    }

    if (!route.destination_ips_.empty() &&
        !route.destination_ips_.contains(connection.localAddress())) {
      continue;
    }

    // if we made it past all checks, the route matches
    return route.cluster_name_;
  }

  // no match, no more routes to try
  return EMPTY_STRING;
}

TcpProxy::TcpProxy(TcpProxyConfigSharedPtr config, Upstream::ClusterManager& cluster_manager)
    : config_(config), cluster_manager_(cluster_manager), downstream_callbacks_(*this),
      upstream_callbacks_(new UpstreamCallbacks(*this)) {}

TcpProxy::~TcpProxy() {
  if (upstream_connection_) {
    read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_destroy_.inc();
    read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_active_.dec();
    read_callbacks_->upstreamHost()->stats().cx_active_.dec();
    read_callbacks_->upstreamHost()
        ->cluster()
        .resourceManager(Upstream::ResourcePriority::Default)
        .connections()
        .dec();
    connected_timespan_->complete();
  }
}

TcpProxyStats TcpProxyConfig::generateStats(const std::string& name, Stats::Scope& scope) {
  std::string final_prefix = fmt::format("tcp.{}.", name);
  return {ALL_TCP_PROXY_STATS(POOL_COUNTER_PREFIX(scope, final_prefix),
                              POOL_GAUGE_PREFIX(scope, final_prefix))};
}

void TcpProxy::initializeReadFilterCallbacks(Network::ReadFilterCallbacks& callbacks) {
  read_callbacks_ = &callbacks;
  ENVOY_CONN_LOG(info, "new tcp proxy session", read_callbacks_->connection());
  config_->stats().downstream_cx_total_.inc();
  read_callbacks_->connection().addConnectionCallbacks(downstream_callbacks_);
  read_callbacks_->connection().setBufferStats({config_->stats().downstream_cx_rx_bytes_total_,
                                                config_->stats().downstream_cx_rx_bytes_buffered_,
                                                config_->stats().downstream_cx_tx_bytes_total_,
                                                config_->stats().downstream_cx_tx_bytes_buffered_});
}

Network::FilterStatus TcpProxy::initializeUpstreamConnection() {
  const std::string& cluster_name = config_->getRouteFromEntries(read_callbacks_->connection());

  Upstream::ThreadLocalCluster* thread_local_cluster = cluster_manager_.get(cluster_name);

  if (thread_local_cluster) {
    ENVOY_CONN_LOG(debug, "Creating connection to cluster {}", read_callbacks_->connection(),
                   cluster_name);
  } else {
    config_->stats().downstream_cx_no_route_.inc();
    read_callbacks_->connection().close(Network::ConnectionCloseType::NoFlush);
    return Network::FilterStatus::StopIteration;
  }

  Upstream::ClusterInfoConstSharedPtr cluster = thread_local_cluster->info();
  if (!cluster->resourceManager(Upstream::ResourcePriority::Default).connections().canCreate()) {
    cluster->stats().upstream_cx_overflow_.inc();
    read_callbacks_->connection().close(Network::ConnectionCloseType::NoFlush);
    return Network::FilterStatus::StopIteration;
  }
  Upstream::Host::CreateConnectionData conn_info = cluster_manager_.tcpConnForCluster(cluster_name);

  upstream_connection_ = std::move(conn_info.connection_);
  read_callbacks_->upstreamHost(conn_info.host_description_);
  if (!upstream_connection_) {
    read_callbacks_->connection().close(Network::ConnectionCloseType::NoFlush);
    return Network::FilterStatus::StopIteration;
  }
  cluster->resourceManager(Upstream::ResourcePriority::Default).connections().inc();

  upstream_connection_->addReadFilter(upstream_callbacks_);
  upstream_connection_->addConnectionCallbacks(*upstream_callbacks_);
  upstream_connection_->setBufferStats(
      {read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_rx_bytes_total_,
       read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_rx_bytes_buffered_,
       read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_tx_bytes_total_,
       read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_tx_bytes_buffered_});
  upstream_connection_->connect();
  upstream_connection_->noDelay(true);

  connect_timeout_timer_ = read_callbacks_->connection().dispatcher().createTimer(
      [this]() -> void { onConnectTimeout(); });
  connect_timeout_timer_->enableTimer(cluster->connectTimeout());

  read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_total_.inc();
  read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_active_.inc();
  read_callbacks_->upstreamHost()->stats().cx_total_.inc();
  read_callbacks_->upstreamHost()->stats().cx_active_.inc();
  connect_timespan_ =
      read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_connect_ms_.allocateSpan();
  connected_timespan_ =
      read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_length_ms_.allocateSpan();

  return Network::FilterStatus::Continue;
}

void TcpProxy::onConnectTimeout() {
  ENVOY_CONN_LOG(debug, "connect timeout", read_callbacks_->connection());
  read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_connect_timeout_.inc();

  // This will close the upstream connection as well.
  read_callbacks_->connection().close(Network::ConnectionCloseType::NoFlush);
}

Network::FilterStatus TcpProxy::onData(Buffer::Instance& data) {
  ENVOY_CONN_LOG(trace, "received {} bytes", read_callbacks_->connection(), data.length());
  upstream_connection_->write(data);
  ASSERT(0 == data.length());
  return Network::FilterStatus::StopIteration;
}

void TcpProxy::onDownstreamEvent(uint32_t event) {
  if ((event & Network::ConnectionEvent::RemoteClose ||
       event & Network::ConnectionEvent::LocalClose) &&
      upstream_connection_) {
    // TODO(mattklein123): If we close without flushing here we may drop some data. The downstream
    // connection is about to go away. So to support this we need to either have a way for the
    // downstream connection to stick around, or, we need to be able to pass this connection to a
    // flush worker which will attempt to flush the remaining data with a timeout.
    upstream_connection_->close(Network::ConnectionCloseType::NoFlush);
  }
}

void TcpProxy::onUpstreamData(Buffer::Instance& data) {
  read_callbacks_->connection().write(data);
  ASSERT(0 == data.length());
}

void TcpProxy::onUpstreamEvent(uint32_t event) {
  if (event & Network::ConnectionEvent::RemoteClose) {
    read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_destroy_remote_.inc();
  }

  if (event & Network::ConnectionEvent::LocalClose) {
    read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_destroy_local_.inc();
  }

  if (event & Network::ConnectionEvent::RemoteClose) {
    if (connect_timeout_timer_) {
      read_callbacks_->upstreamHost()->cluster().stats().upstream_cx_connect_fail_.inc();
      read_callbacks_->upstreamHost()->stats().cx_connect_fail_.inc();
    }

    read_callbacks_->connection().close(Network::ConnectionCloseType::FlushWrite);
  } else if (event & Network::ConnectionEvent::Connected) {
    connect_timespan_->complete();
  }

  if (connect_timeout_timer_) {
    connect_timeout_timer_->disableTimer();
    connect_timeout_timer_.reset();
  }
}

} // Filter
} // Envoy


text: create schema if not exists {{name}};

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
    <applicationVisibilities>
        <application>LWC_Recipes</application>
        <visible>true</visible>
    </applicationVisibilities>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.AccountId</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.AssistantName</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.AssistantPhone</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Birthdate</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>false</editable>
        <field>Contact.CleanStatus</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Department</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Description</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.DoNotCall</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Email</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Fax</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.HasOptedOutOfEmail</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.HasOptedOutOfFax</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.HomePhone</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Jigsaw</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.LeadSource</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.MailingAddress</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.MobilePhone</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.OtherAddress</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.OtherPhone</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Phone</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Picture__c</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.ReportsToId</field>
        <readable>true</readable>
    </fieldPermissions>
    <fieldPermissions>
        <editable>true</editable>
        <field>Contact.Title</field>
        <readable>true</readable>
    </fieldPermissions>
    <hasActivationRequired>false</hasActivationRequired>
    <label>recipes</label>
    <objectPermissions>
        <allowCreate>true</allowCreate>
        <allowDelete>true</allowDelete>
        <allowEdit>true</allowEdit>
        <allowRead>true</allowRead>
        <modifyAllRecords>true</modifyAllRecords>
        <object>Contact</object>
        <viewAllRecords>true</viewAllRecords>
    </objectPermissions>
    <tabSettings>
        <tab>Apex</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Aura_Interoperability</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Composition</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Data_Service</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Events</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Hello</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Misc_Techniques</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Navigation</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Parent_to_Child</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Pub_Sub</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>Wire</tab>
        <visibility>Visible</visibility>
    </tabSettings>
    <tabSettings>
        <tab>X3rd_Party_Libs</tab>
        <visibility>Visible</visibility>
    </tabSettings>
</PermissionSet>


text:
{% extends "base.html" %}

{% block breadcrumb %}

    home
     :  Make Predictions for the {{ match_type }}

{% endblock %}
{% block main_content %}

Make Predictions for the {{ match_type }}

Your predictions have been saved!

Edit your predictions

Return to the Home Page

{% if Err_found %}
    {% if MatchType_not_Found %}
        Sorry!  The match type was not found.
    {% endif %}
    {% if Not_logged_in %}
        Sorry!  You are not logged in.
    {% endif %}
    return to list
{% endif %}

{% if predictions %}

    {% include "predictions/ko_round/your_ko_predictions_table.html" %}
{% endif %}

{% endblock %}


text:
'use strict'

var should = require('should')
var middlewareLib = require('../lib/lib')
var handleableLib = require('quiver-handleable')

describe('middleware test', function() {
  var handlerBuilder = function(config, callback) {
    should.exists(config.middleware1Loaded)
    should.exists(config.middleware2Loaded)

    var handler = function(args, inputStreamable, callback) {
      callback(null, inputStreamable)
    }

    callback(null, handler)
  }

  var middleware1 = function(config, handlerBuilder, callback) {
    should.not.exists(config.middleware1Loaded)
    config.middleware1Loaded = true
    handlerBuilder(config, callback)
  }

  var middleware2 = function(config, handlerBuilder, callback) {
    should.exists(config.middleware1Loaded)
    should.not.exists(config.middleware2Loaded)

    config.middleware2Loaded = true
    handlerBuilder(config, callback)
  }

  it('dependency loading test', function(callback) {
    var middleware1Loader = middlewareLib.createMiddlewareLoadingMiddleware('middleware1')
    var middleware2Loader = middlewareLib.createMiddlewareLoadingMiddleware('middleware2')

    var managedMiddleware2 = middlewareLib.combineMiddlewares([middleware1Loader, middleware2])
    var managedHandlerBuilder = middlewareLib.createMiddlewareManagedHandlerBuilder(middleware2Loader, handlerBuilder)

    var config = {
      quiverMiddlewares: {
        middleware1: middleware1,
        middleware2: managedMiddleware2
      }
    }

    managedHandlerBuilder(config, function(err, handler) {
      if(err) return callback(err)

      should.exists(handler)
      callback()
    })
  })

  it('cyclic dependency prevention test', function(callback) {
    var middleware1Loader = middlewareLib.createMiddlewareLoadingMiddleware('middleware1')
    var middleware2Loader = middlewareLib.createMiddlewareLoadingMiddleware('middleware2')

    var managedMiddleware1 = middlewareLib.combineMiddlewares([middleware2Loader, middleware1])
    var managedMiddleware2 = middlewareLib.combineMiddlewares([middleware1Loader, middleware2])

    managedMiddleware1 = middlewareLib.createCyclicPreventionMiddleware('middleware1', managedMiddleware1)
    managedMiddleware2 = middlewareLib.createCyclicPreventionMiddleware('middleware2', managedMiddleware2)

    var managedHandlerBuilder = middlewareLib.createMiddlewareManagedHandlerBuilder(middleware2Loader, handlerBuilder)

    var config = {
      quiverMiddlewares: {
        middleware1: managedMiddleware1,
        middleware2: managedMiddleware2
      }
    }

    managedHandlerBuilder(config, function(err, handler) {
      should.exists(err)

      callback()
    })
  })

  it('install once middleware test', function(callback) {
    var middleware1Loader = middlewareLib.createMiddlewareLoadingMiddleware('middleware1')
    var middleware2Loader = middlewareLib.createMiddlewareLoadingMiddleware('middleware2')

    var managedMiddleware1 = middlewareLib.createInstallOnceMiddleware('middleware1', middleware1)
    var managedMiddleware2 = middlewareLib.createInstallOnceMiddleware('middleware2', managedMiddleware2)

    managedMiddleware2 = middlewareLib.combineMiddlewares([middleware1Loader, middleware2])

    var handlerMiddleware = middlewareLib.combineMiddlewares([middleware1Loader, middleware2Loader])
    var managedHandlerBuilder = middlewareLib.createMiddlewareManagedHandlerBuilder(handlerMiddleware, handlerBuilder)

    var config = {
      quiverMiddlewares: {
        middleware1: managedMiddleware1,
        middleware2: managedMiddleware2
      }
    }

    managedHandlerBuilder(config, function(err, handler) {
      should.not.exists(err)

      callback()
    })
  })

  it('extend handleable test', function(callback) {
    var handler = function(args, inputStreamable, callback) {
      callback(null, inputStreamable)
    }

    var handleable = {
      toStreamHandler: function() {
        return handler
      },
      extendedFeature: function() {
        return true
      }
    }

    handleableLib.makeExtensible(handleable.extendedFeature)

    var handleableBuilder = function(config, callback) {
      callback(null, handleable)
    }

    var filter = function(config, handler, callback) {
      callback(null, handler)
    }

    var streamMiddleware = middlewareLib.createMiddlewareFromFilter(filter)
    var handleableMiddleware = middlewareLib.middlewareToHandleableMiddleware(
      handleableLib.streamHandlerConvert, streamMiddleware)

    handleableMiddleware({}, handleableBuilder, function(err, handleable) {
      if(err) return callback(err)

      should.exists(handleable.toStreamHandler)
      should.exists(handleable.extendedFeature)

      callback()
    })
  })
})


text:
const babelify = require('babelify');
const browserify = require('browserify');
const buffer = require('vinyl-buffer');
const cssAutoPrefixer = require('gulp-autoprefixer');
const gulp = require('gulp');
const less = require('gulp-less');
const logger = require('./util/logger');
const mold = require('mold-source-map');
const nodemon = require('gulp-nodemon');
const path = require('path');
const config = require('./config/config');
const rename = require('gulp-rename');
const source = require('vinyl-source-stream');
const sourcemaps = require('gulp-sourcemaps');

// Compiles assets and start the nodemon server.
gulp.task('default', ['less:compile', 'jsx:compile', 'dev']);

// Starts the nodemon server that automatically compiles assets and restarts on relevant file changes.
gulp.task('dev', (cb) => {
    let started = false;
    return nodemon({
        script: 'app.js',
        ignore: ['public/css/*', 'public/js/*', 'log/*'],
        ext: 'js,jsx,less,ejs,json',
        verbose: false,
        tasks: (changedFiles) => {
            const tasks = new Set();
            changedFiles.forEach((file) => {
                logger.info(`Changed: ${file}`);
                if (path.extname(file) === '.less')
                    tasks.add('less:compile');
                if (path.extname(file) === '.jsx')
                    tasks.add('jsx:compile');
            });
            return [...tasks];
        }
    }).on('start', () => {
        if (!started) {
            cb();
            started = true;
        }
    });
});

// Compiles the LESS file 'main.less' in 'assets/less' into CSS file 'main.css' in 'public/css'
gulp.task('less:compile', () => {
    return gulp.src('assets/less/main.less')
        .pipe(less())
        .on('error', (err) => {
            logger.error(`compiling LESS\n\tFile: ${err.filename}\n\tLine: ${err.line}\n\tType: ${err.type}\n\tMessage: ${err.message}`);
            return this;
        })
        .pipe(cssAutoPrefixer({
            browsers: ['> 1%'],
            cascade: false
        }))
        .pipe(rename(`main.css`))
        .pipe(gulp.dest('public/css'));
});

// Compiles and bundles the JSX file 'main.jsx' in 'assets/jsx' into JS file 'main.js' to 'public/css'
gulp.task('jsx:compile', () => {
    return browserify({ entries: 'assets/jsx/main.jsx', extensions: ['.js', '.jsx'], debug: true })
        .transform(babelify, { presets: ['es2015'] })
        .bundle()
        .on('error', (err) => {
            logger.error(`compiling JSX\n\tFile: ${err.filename}\n\tMessage: ${err.message}`);
        })
        .pipe(mold.transformSourcesRelativeTo('./'))
        .pipe(source('main.jsx'))
        .pipe(buffer())
        .pipe(rename('main.js'))
        .pipe(sourcemaps.init({ loadMaps: true }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('public/js'));
});


text:
//#define DEBUG_LOAD
//#define TRACE_LOAD_FAIL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.ComponentModel;
using System.Collections.Specialized;
//using LionFire.Input; REVIEW
//using LionFire.Extensions.DefaultValues; REVIEW
using Microsoft.Extensions.Logging;
using LionFire.Persistence;
using System.Threading.Tasks;
using LionFire.MultiTyping;
using System.Reflection;
using LionFire.Referencing;

namespace LionFire.ObjectBus
{
    //   - Abstract Reference
    public abstract class MinimalHandleBase<ObjectType> : IHandle<ObjectType>
        , IHandlePersistence
        , ITreeHandle
        , IChangeableReferencable
        where ObjectType : class
    {
        #region Construction

        public MinimalHandleBase(ObjectType obj = null, bool freezeObjectIfProvided

#if AOT
		                   = false
#else
 = true
#endif
)
        {

            this._object = obj;
            if (obj != null && freezeObjectIfProvided)
            {
                IsObjectReferenceFrozen = true;
            }

            if (typeof(ObjectType) == typeof(object)) { l.LogTrace("HandleBase2<object>: " + this.ToString()); }
        }

        internal MinimalHandleBase(string uri, ObjectType obj = null, bool freezeObjectIfProvided = true)
            : this(obj)
        {
            this.Reference = uri.ToReference();
            this._object = obj;

            if (typeof(ObjectType) == typeof(object)) { l.LogTrace("HandleBase2<object>: " + this.ToString()); }
        }

        public MinimalHandleBase(IReference reference, ObjectType obj = null, bool freezeObjectIfProvided = true)
            : this(obj, freezeObjectIfProvided)
        {
            this.Reference = reference;

            //if (LoadOnDemandByDefault)
            //{
            //    RetrieOnDemandByDefault = true;
            //}
            if (typeof(ObjectType) == typeof(object)) { l.LogTrace("HandleBase2<object>: " + this.ToString()); }
        }

        public MinimalHandleBase(IReferencable referencable, ObjectType obj = null, bool freezeObjectIfProvided = true)
            : this(obj, freezeObjectIfProvided)
        {
            IReference reference = referencable.Reference;

            if (!reference.IsValid())
            {
                throw new ArgumentException("referencable.Reference must be valid");
            }

            this.Reference = referencable.Reference;
            if (typeof(ObjectType) == typeof(object)) { l.LogTrace("HandleBase2<object>: " + this.ToString()); }
        }

        #endregion

        #region Reference

        public abstract IReference Reference
        {
            get;
            set;
        }

        //#if AOT
        //object IKeyed<object>.Key { get { return Key; } }
        //#endif
        public string Key
        {
            get
            {
                return Reference.Key;
            }
        }

        protected void OnReferenceChangedFrom(IReference oldReference)
        {
            var ev = ReferenceChangedForFrom;
            if (ev != null) ev(this, oldReference);
        }

        public event Action<IChangeableReferencable, IReference> ReferenceChangedForFrom;

        #endregion

        #region INotifyPropertyChanged

        #region INotifyPropertyChanged Implementation

        public event PropertyChangedEventHandler ObjectPropertyChanged
        {
            add
            {
                if (propertyChanged == null)
                {
                    if (this._object != null)
                    {
                        INotifyPropertyChanged inpc = _object as INotifyPropertyChanged;
                        if (inpc != null)
                        {
                            inpc.PropertyChanged += inpc_PropertyChanged;
                        }
                    }
                }
                propertyChanged += value;
            }
            remove
            {
                propertyChanged -= value;
                if (propertyChanged == null)
                {
                    if (this._object != null)
                    {
                        INotifyPropertyChanged inpc = _object as INotifyPropertyChanged;
                        if (inpc != null)
                        {
                            inpc.PropertyChanged += inpc_PropertyChanged;
                        }
                    }
                }
            }
        }
        event PropertyChangedEventHandler propertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            var ev = propertyChanged;
            if (ev != null) ev(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion

        #endregion

        #region Object

        #region IsObjectFrozen

        [Ignore]
        public bool IsObjectReferenceFrozen
        {
            get { return isObjectReferenceFrozen; }
            set
            {
                if (isObjectReferenceFrozen == value) return;
                if (value == false && isObjectReferenceFrozen)
                {
                    throw new NotSupportedException("IsObjectReferenceFrozen cannot be set to false after setting to true.");
                }
#if AOT
				if(value)
				{
					throw new NotSupportedException("IsObjectReferenceFrozen on AOT build");
				}
#endif
                isObjectReferenceFrozen = value;
            }
        }
        private bool isObjectReferenceFrozen;

        #endregion

        //protected bool loadObjectOnDemand { get { return SpecialObject.LoadOnDemand.Equals(_object); } }

        //public bool? LoadObjectOnDemand
        //{
        //    get
        //    {
        //        if (SpecialObject.LoadOnDemand.Equals(_object)) return true;
        //        else if (_object == null) return false;
        //        else return null;
        //    }
        //    set
        //    {
        //        if (value == true)
        //        {
        //            SetObjectToNull();
        //            if (_object == null)
        //            {
        //                _object = SpecialObject.LoadOnDemand;
        //            }
        //            // else ?
        //        }
        //        else if (value == false)
        //        {
        //            if (SpecialObject.LoadOnDemand.Equals(_object))
        //            {
        //                _object = null;
        //            }
        //            // else ?
        //        }
        //        // else ?
        //    }
        //}

        //public static bool LoadOnDemandByDefault = true;

#if NonGenericHandles
        object IReadHandle.Object
        {
            get
            {
                //l.Trace("ZX HandleBase2.get_Object, iReadHandle");
                return this.Object;
            }
        }
#endif

        public virtual void ForgetObject()
        {
            forgotObject = true;
        }

#if NonGenericHandles
#if AOT && true // AOTTEMP
#else
        object IHandle.Object
        {
            get
            {
                //l.Trace("ZX HandleBase2.get_Object, IHandle");

                return this.Object;
            }
            set
            {
                this.Object = (ObjectType)value;
            }
        }
#endif
#endif

        public ObjectType ObjectOrThrow
        {
            get
            {
                var result = Object;
                if (result == null)
                {

                    throw new ObjectNotFoundException($"Failed to load object of type {typeof(ObjectType).Name} at ${this.Reference.Path}");
                }
                return result;
            }
        }
        [Ignore]
        public ObjectType Object
        {
            get
            {
                //System.Threading.Thread.MemoryBarrier();
                //				l.Info("ZX HandleBase2.get_Object");
                //System.Threading.Thread.MemoryBarrier();

                if (_object == null
                    //&& RetrieveOnDemand
                    )
                {
                    TryResolveObject().WaitSafe();
                }
                else if (forgotObject)
                {
                    //forgotObject = false;
                    TryResolveObject().WaitSafe();
                }

#if AOT
//				l.Info("ZX HandleBase2.get_Object got " + (_object== null ? "null" : _object.GetType().Name));

				return (ObjectType)_object;
#else
                return _object;
#endif
            }
        }
#if AOT
		protected object _object;
#else
        protected ObjectType _object;
#endif

        public void SetObject(ObjectType value)
        {
            forgotObject = false;
            if (System.Object.ReferenceEquals(_object, value)) return;

            if (IsObjectReferenceFrozen)
            {
                AssignFrom(value);

                //throw new InvalidOperationException("Object is frozen.");
            }
            else
            {
                //if (value == null)
                //{
                //    if(SpecialObject.LoadOnDemand.Equals(_object))
                //    {
                //        return;
                //    }

                //    SetObjectToNull();
                //    return;
                //}

#if TODO // TOMIGRATE
                if (_object != null && EffectiveAutoSave)
                {
                    AutoSaveManager.Instance.Unregister(this);
                }
#endif
                var wasPropertyChangedEventsAttached = IsPropertyChangedEventsAttached || IsLegacyObjectChangedEnabled;

                IsPropertyChangedEventsAttached = false;

                _object = value;

                if (_object != null && wasPropertyChangedEventsAttached)
                {
                    IsPropertyChangedEventsAttached = wasPropertyChangedEventsAttached;
                }
#if TODO // TOMIGRATE
                if (_object != null && EffectiveAutoSave)
                {
                    AutoSaveManager.Instance.Register(this);
                }
#endif
                OnObjectChanged();
            }
        }

        /// <summary>
        /// Subsequent call to get_Object will re-retrieve the Object.
        /// We don't forget the _object by setting it to null in case
        /// the reference is pinned.
        /// </summary>
        protected bool forgotObject;

        public ObjectType ObjectOrCreate
        {
            get
            {
                if (Object == null)
                {
                    SetObject(CreateDefault());
                }
                return Object;
            }
        }

        #region ObjectField

        public ObjectType ObjectField
        {
            get
            {
#if AOT
				return (ObjectType)_object;
#else
                return _object;
#endif
            }
            set { _object = value; }
        }

        #endregion

        private void RegisterForAutoSave(object obj)
        {

        }

        public bool IsLegacyObjectChangedEnabled { get { return _legacyObjectChanged != null; } }
        public event ObjectChanged LegacyObjectChanged
        {
            add
            {
                _legacyObjectChanged += value;
                IsPropertyChangedEventsAttached = true;
            }
            remove
            {
                _legacyObjectChanged -= value;
                IsPropertyChangedEventsAttached = _legacyObjectChanged == null;
            }
        }
        private event ObjectChanged _legacyObjectChanged;

        public bool IsObjectChangedEnabled { get { return _objectChanged != null; } }
        public event Action<IReadHandle<ObjectType>, ObjectType, ObjectType> ObjectChanged
        {
            add
            {
                _objectChanged += value;
                IsPropertyChangedEventsAttached = true;
            }
            remove
            {
                _objectChanged -= value;
                IsPropertyChangedEventsAttached = _objectChanged == null;
            }
        }
        private event Action<IReadHandle<ObjectType>, ObjectType, ObjectType> _objectChanged;

        #region Propety Changed Events

        #region IsPropertyChangedEventsAttached

        public bool IsPropertyChangedEventsAttached
        {
            get { return isPropertyChangedEventsAttached; }
            set
            {
                if (isPropertyChangedEventsAttached == value) return;

                isPropertyChangedEventsAttached = value;
                if (_object == null)
                {
                    //l.Warn("_object == null during change to IsPropertyChangedEventsAttached.  This should only be set when _object is set.");
                    return;
                }
                //l.Fatal("(TEMP) IsPropertyChangedEventsAttached: " + value + " " + this.ToString());

                if (isPropertyChangedEventsAttached)
                {
                    INotifyPropertyChanged inpc = _object as INotifyPropertyChanged;
                    if (inpc != null)
                    {
                        inpc.PropertyChanged += inpc_PropertyChanged;
                    }
#if TOMIGRATE
                    IPropertyChanged ipc = _object as IPropertyChanged;
                    if (ipc != null)
                    {
                        ipc.PropertyValueChanged += ipc_PropertyValueChanged;
                    }
#endif
                    INotifyCollectionChanged inc = _object as INotifyCollectionChanged;
                    if (inc != null)
                    {
                        inc.CollectionChanged += inc_CollectionChanged;
                    }
                }
                else
                {
                    INotifyPropertyChanged inpc = _object as INotifyPropertyChanged;
                    if (inpc != null)
                    {
                        inpc.PropertyChanged -= inpc_PropertyChanged;
                    }
#if TOMIGRATE
                    IPropertyChanged ipc = _object as IPropertyChanged;
                    if (ipc != null)
                    {
                        ipc.PropertyValueChanged -= ipc_PropertyValueChanged;
                    }
#endif
                    INotifyCollectionChanged inc = _object as INotifyCollectionChanged;
                    if (inc != null)
                    {
                        inc.CollectionChanged -= inc_CollectionChanged;
                    }
                }

            }
        }
        private bool isPropertyChangedEventsAttached;

        #endregion

        void inc_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            var ev = _legacyObjectChanged;
            if (ev != null) ev(this, "(CollectionChanged)");
        }

        void ipc_PropertyValueChanged(string propertyName)
        {
            var ev = _legacyObjectChanged;
            if (ev != null) ev(this, propertyName);
        }

        void inpc_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var ev = _legacyObjectChanged;
            if (ev != null) ev(this, e.PropertyName);
        }

        #endregion

        protected IReadonlyMultiTyped ObjectMT { get { return _object as IReadonlyMultiTyped; } }

        protected IMultiTyped ObjectEMT { get { return _object as IMultiTyped; } }

        //private void set_Object_Internal(T value)
        //{
        //    if (System.Object.ReferenceEquals(_object, value)) return;
        //    _object = value;
        //    OnObjectChanged();
        //}

        public bool HasObject
        {
            get
            {
                return _object != null;
                //&& !loadObjectOnDemand;
            }
        }

        #endregion

        #region Persistence

        #region Create / Update

        private const bool saveCreatedObject = true; // HACK Hackish to save?  Or does "Create" include saving?
        public void RetrieveOrCreate()
        {
            if (!TryEnsureRetrieved())
            {
                ConstructDefault();
                if (saveCreatedObject) { Save(); }
            }
        }

        bool IHandlePersistence.RetrieveOrCreateDefault(object defaultValue)
        {
            return RetrieveOrCreateDefault((ObjectType)defaultValue);
        }
        bool IHandlePersistence.RetrieveOrCreateDefault(Func<object> defaultValue)
        {
            return RetrieveOrCreateDefault_Object(defaultValue);
        }

        public bool RetrieveOrCreateDefault(ObjectType defaultValue)
        {
            if (!TryEnsureRetrieved())
            {
                Object = defaultValue;
                return false;
            }
            return true;
        }

        public bool RetrieveOrCreateDefault(Func<ObjectType> defaultValue)
        {
            if (!TryEnsureRetrieved())
            {
                Object = defaultValue();
                return false;
            }
            return true;
        }

        public bool RetrieveOrCreateDefault_Object(Func<object> defaultValue)
        {
            if (!TryEnsureRetrieved())
            {
                Object = (ObjectType)defaultValue();
                return false;
            }
            return true;
        }

        #endregion

        #region Create

        public void Create()
        {
            EnsureConstructed();
            OBus.Create(this.Reference, this.Object); // Throws if already exists

            //OBus.CreateOrOverwrite(this.Reference, this.Object);
        }

        public void CreateOrOverwrite()
        {
            EnsureConstructed();
            Save();
        }

        #endregion

        #region Construction (No persistence)

        private ObjectType CreateDefault(bool applyDefaultValues = true)
        {
            ObjectType result;
            if (typeof(ObjectType) == typeof(object))
            {
                if (Reference == null) throw new ArgumentException("Reference.Type must be set when using non-generic Handle, or when the generic type is object.");

                if (Reference.Type == null)
                {
                    throw new ArgumentException("Reference.Type must be set when using non-generic Handle, or when the generic type is object.");
                }
                result = (ObjectType)Activator.CreateInstance(Reference.Type);
            }
            else
            {
                result = (ObjectType)Activator.CreateInstance(typeof(ObjectType));
            }
            if (applyDefaultValues) { DefaultValueUtils.ApplyDefaultValues(result); }
            return result;
        }
        public void ConstructDefault(bool applyDefaultValues = true)
        {
            Object = CreateDefault(applyDefaultValues);
        }
        private void ConstructDefaultNoEvents(bool applyDefaultValues = true)
        {
            _object = CreateDefault(applyDefaultValues);
        }

        public void EnsureConstructed() // REVIEW: What should be done here?
        {
            //RetrieveOrCreateDefault(); ??

            if (Object == null)
            {
                ConstructDefault();
            }
        }
        private void EnsureConstructedNoEvents() // REVIEW: What should be done here?
        {
            if (_object == null)
            {
                ConstructDefaultNoEvents();
            }
        }

        #endregion

        #region Delete

        public virtual bool? CanDelete()
        {
            bool? result = OBus.CanDelete(this.Reference);
            return result;
        }
        public virtual bool TryDelete(bool preview = false)
        {
            bool result = OBus.TryDelete(this.Reference, preview);
            if (result && !preview)
            {
                OnDeleted();
            }
            return result;
        }

        public virtual void Delete()
        {
            OBus.Delete(this.Reference); // Throws if doesn't exist

            // OLD:
            //Object = null;
            //Object = SpecialObject.NullObject;

            OnDeleted();
        }

        #endregion

        #region Move / Copy

        public void Copy(IReference newReference)
        {
            throw new NotImplementedException();
        }
        public void Move(IReference newReference)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region AssignFrom

        void IHandlePersistence.AssignFrom(object other)
        {
            AssignFrom((ObjectType)other);
        }

        #region (Static) ObjectTypeAssignmentMode

        const AssignmentMode DefaultAssignmentMode = AssignmentMode.DeepCopy;
        internal static AssignmentMode ObjectTypeAssignmentMode // MOVE?
        {
            get
            {
                if (assignmentMode == LionFire.AssignmentMode.Unspecified)
                {
                    var attr = typeof(ObjectType).GetCustomAttribute<AssignmentAttribute>();
                    if (attr != null)
                    {
                        assignmentMode = attr.AssignmentMode;
                    }
                    else
                    {
                        assignmentMode = DefaultAssignmentMode;
                    }
                }
                return assignmentMode;
            }
        }
        static AssignmentMode assignmentMode = AssignmentMode.Unspecified;

        #endregion

        public void AssignFrom(ObjectType other, AssignmentMode assignmentMode = AssignmentMode.Unspecified) // Move to generic extension method?
        {
#if AOT
			throw new NotSupportedException("AssignFrom not supported in AOT");
#else

            if (other == null) return; // Empty out this?

            if (assignmentMode == AssignmentMode.Unspecified)
            {
                assignmentMode = ObjectTypeAssignmentMode;
            }

            EnsureConstructedNoEvents();

            // FUTURE: AssignIgnore attribute
            //#if AOT
            //            LionFire.Extensions.AssignFrom.AssignFromUtils.AssignFrom(this._object, other);
            //#else
            LionFire.Extensions.AssignFrom.AssignFromUtils.AssignFrom<ObjectType>(this._object, other, assignmentMode);
            //#endif
#endif
        }
        #endregion

        #region Retrieve

        //public bool RetrieveOnDemand { get; set; }

        public async Task Retrieve(object persistenceContext = null)
        {
            //if (this.Reference == null) throw new ArgumentException("this.Reference is null");

            if (await TryResolveObject(persistenceContext) == false) throw new ObjectNotFoundException();

            //    ObjectType result;
            //    if (typeof(ObjectType) == typeof(object))
            //    {
            //        result = (ObjectType)OBus.Get(this.Reference);
            //    }
            //    else
            //    {
            //        result = OBus.GetAs<ObjectType>(this.Reference);
            //    }
            //    OnRetrieved(result);
        }

        public virtual ObjectType TryGetOrCreate()
        {
            if (!HasObject)
            {
                TryResolveObject().WaitSafe();
                if (!HasObject) { ConstructDefault(); }
            }
            return Object;
        }

        //public virtual bool TryReload(bool setToNullOnFail = true)
        //{
        //}

        public virtual bool QueryExistance()
        {
            return Object != null;
        }

        public abstract Task<bool> TryResolveObject(object persistenceContext = null);

        public void EnsureRetrieved()
        {
            bool result = TryEnsureRetrieved();
            if (!result) throw new ObjectNotFoundException();
        }

        /// <summary>
        /// If Object is null, attempts to retrieve.  Returns true if Object != null
        /// </summary>
        /// <returns></returns>
        public bool TryEnsureRetrieved(object persistenceContext = null)
        {
            if (_object != null) return true;

            if (Reference != null)
            {
                TryResolveObject(persistenceContext).WaitSafe();
            }
            return _object != null;
        }

        #endregion

        #region Save

        #region AutoSave

        public bool? AutoSave
        {
            get { return autoSave; }
            set
            {
                if (true == value) throw new NotImplementedException("TODO");
                //if (autoSave == value) return;
                //var oldEffectiveAutoSave = EffectiveAutoSave;
                //autoSave = value;
                ////l.Info("TEMP - AutoSave = " + value + " for " + this);
                //if (oldEffectiveAutoSave != EffectiveAutoSave)
                //{
                //    if (EffectiveAutoSave)
                //    {
                //        AutoSaveManager.Instance.Register(this);
                //    }
                //    else
                //    {
                //        AutoSaveManager.Instance.Unregister(this);
                //    }
                //}
                //OnPropertyChanged("AutoSave");
            }
        }
        private bool? autoSave;

        public bool EffectiveAutoSave
        {
            get
            {
                if (AutoSave.HasValue) return AutoSave.Value;
                return InheritedAutoSave;
            }
        }

        protected bool InheritedAutoSave
        {
            get
            {
#if TODO
                if (AutoSaveManager.AutoSaveTypes.Contains(typeof(ObjectType))) return true;
                if (_object != null && AutoSaveManager.AutoSaveTypes.Contains(_object.GetType())) return true;
#endif
                return false;
            }
        } // FUTURE: Actually inherit

        #endregion

        private bool AllowOverwriteOnSave = true;

        public event Action<IHandle> Saving;

        Task ISaveable.Save(object persistenceContext)
        {
            return Save(persistenceContext);
        }

        // REVIEW REFACTOR: move allowDelete and preview into persistenceContext, perhaps as enum flags
        public virtual Task Save(object persistenceContext = null, bool allowDelete = false, bool preview = false)
        {
            Saving?.Invoke(this);
            if (!HasObject)
            {
                if (allowDelete)
                {
                    TryDelete(preview);
                }
                else
                {
                    throw new ArgumentException("Attempt to save null when allowDelete == false");
                }
                return Task.CompletedTask;
            }

            if (AllowOverwriteOnSave)
            {
                OBus.Set(this.Reference, this._object);
            }
            else
            {
                if (IsPersisted)
                {
                    OBus.Set(this.Reference, this._object); // TODO: Use update instead to make sure it wasn't deleted out from under us

                    // FUTURE: Some kind of threadsafe versioning logic to make sure the object wasn't updated from under us.
                }
                else
                {
                    OBus.Create(this.Reference, this._object); // Throws if already exists
                }
            }

            OnSaved(); // Sets IsPersisted = true
            return Task.CompletedTask;
        }

        #endregion

        #region Children Names

        public virtual IEnumerable<string> GetChildrenNames(bool includeHidden = false)
        {
            return OBus.GetChildrenNames(this.Reference).Where(n => includeHidden || !VosPath.IsHidden(n));
        }

        public virtual IEnumerable<string> GetChildrenNamesOfType<ChildType>() where ChildType : class, new()
        {
            return OBus.GetChildrenNamesOfType<ChildType>(this.Reference);
        }
        public virtual IEnumerable<string> GetChildrenNamesOfType(Type childType)
        {
            return OBus.GetChildrenNamesOfType(childType, this.Reference);
        }

        public virtual IEnumerable<IHandle> GetChildren()
        {
            return OBus.GetChildren(this.Reference);
        }

#if !AOT
        public virtual IEnumerable<IHandle<ChildType>> GetChildrenOfType<ChildType>() where ChildType : class//,new()
        {
            return OBus.GetChildrenOfType<ChildType>(this.Reference);
        }
#endif
        public virtual IEnumerable<IHandle> GetChildrenOfType(Type childType)
        {
            return OBus.GetChildrenOfType(this.Reference, childType);
        }

        #endregion

        #endregion

        #region Change Events

        protected virtual void OnObjectChanged()
        {
            if (_object != null)
            {
                IReferencable referenceable = _object as IReferencable;
                if (referenceable != null)
                {
                    if (Reference == null)
                    {
                        this.Reference = referenceable.Reference;
                    }
                    else
                    {
                        if (!Reference.Equals(referenceable.Reference))
                        {
                            l.Warn("HandleBase Object changed to an object with refernce: " + referenceable.Reference + " but this.Reference is: " + this.Reference + " (MountReference: " + MountReference + ")");
                        }
                    }
                }
            }
        }

        protected virtual IReference MountReference
        {
            get { return null; }
        }

        #endregion

        #region Persistence Events

        #region IsPersisted

        public bool IsPersisted
        {
            get { return isPersisted; }
            set
            {
                if (isPersisted == value) return;
                isPersisted = value;

                //var ev = IsPersistedChanged;
                //if (ev != null) ev();
            }
        }
        private bool isPersisted;

        //public event Action IsPersistedChanged;

        #endregion

        protected void OnDeleted()
        {
            IsPersisted = false;
        }

        //public IEnumerable<IHandle> ResolvedTo { get { return ResolvedTo; } }
        //private SortedSet<IHandle> resolvedTo;

        //private virtual void OnResolvedTo(IHandle handle)
        //{
        //    if (resolvedTo == null) resolvedTo = new SortedSet<IHandle>();
        //    if (!resolvedTo.Contains(handle))
        //    {
        //        resolvedTo.Add(handle);
        //    }
        //}

        protected virtual void OnRetrieved(ObjectType retrievedObject)
        {
            //Log.Info("ZX HandleBase2.OnRetrieved");

            if (retrievedObject == null)
            {
                IsPersisted = false;
                return;
            }

            IHasHandleSetter hasHandle = retrievedObject as IHasHandleSetter;
            if (hasHandle != null)
            {
                hasHandle.Handle = this;
            }

            IsPersisted = true;

            if (IsObjectReferenceFrozen)
            {
#if AOT
				throw new NotSupportedException("IsObjectReferenceFrozen on AOT build");
#else
                AssignFrom(retrievedObject);
#endif
            }
            else
            {
                this.Object = retrievedObject;
            }
        }

        protected void OnSaved()
        {
            IsPersisted = true;
        }

        #endregion

        #region IHasHandle

        [Ignore]
        public IHandle<ObjectType> Handle
        {
            get { return this; }
            set { throw new NotSupportedException("this is a handle.  Cannot set this.Handle"); }
        }

        #endregion

        public override string ToString()
        {
            if (HasObject)
            {
                return String.Concat("<", (Reference == null ? "null" : Reference.ToString()), ">");
            }
            else
            {
                return String.Concat(">", (Reference == null ? "null" : Reference.ToString()), "<");
            }
        }

        #region IReadonlyMultiTyped

        public object this[Type type]
        {
            get
            {
                if (!TryEnsureRetrieved()) return null;

                if (type.IsAssignableFrom(_object.GetType()))
                {
                    return _object;
                }

                IReadonlyMultiTyped mtObj = _object as IReadonlyMultiTyped;

                if (mtObj != null)
                {
                    object mtChild = mtObj[type];
                    if (mtChild != null)
                    {
                        return mtChild;
                    }
                }
                return null;
            }
        }

        public bool IsPersistable<T>()
        {
            var attr = typeof(T).GetCustomAttribute<IgnoreAttribute>();
            if (attr != null && attr.Ignore.HasFlag(LionSerializeContext.Persistence)) return false;

            return true;
        }
        public bool IsPersistable(Type T)
        {
            var attr = T.GetCustomAttribute<IgnoreAttribute>();
            if (attr != null && attr.Ignore.HasFlag(LionSerializeContext.Persistence)) return false;

            return true;
        }

#if !NoGenericMethods
        public T AsType<T>() where T : class
        {
            if (!HasObject)
            {
                if (!IsPersistable<T>() && !IsPersistable<ObjectType>()) return null;
                if (!TryEnsureRetrieved()) return null;
            }

            T result = _object as T;
            if (result != null) return result;

            IReadonlyMultiTyped mtObj = ObjectMT;

            if (mtObj != null)
            {
                result = mtObj.AsType<T>();
            }

            return result;
        }
#endif
        [AotReplacement]
        public object AsType(Type T)
        {
            if (!HasObject)
            {
                if (!IsPersistable(T) && !IsPersistable(typeof(ObjectType))) return null;
                if (!TryEnsureRetrieved()) return null;
            }

            if (_object != null && T.IsAssignableFrom(_object.GetType()))
            {
                return _object;
            }

            IReadonlyMultiTyped mtObj = ObjectMT;

            object result = null;
            if (mtObj != null)
            {
                result = mtObj.AsType(T);
            }

            return result;
        }

#if !NoGenericMethods
        public T AsTypeOrCreate<T>(bool allowMerge = true, Func<T> factory = null) where T : class
        {
            T obj = this.AsType<T>();
            if (obj == null)
            {
                if (HasObject)
                {
                    if (allowMerge && ObjectEMT != null)
                    {
                        // Ok, merge
                    }
                    else
                    {
                        if (ObjectEMT != null && !allowMerge)
                        {
                            throw new VosException("AsTypeOrCreate: allowMerge is false but object is a IMultiType");
                        }
                        else
                        {
                            throw new VosException("AsTypeOrCreate: already has object of another type");
                        }
                    }
                }

                if (ObjectEMT != null && !typeof(ObjectType).IsAssignableFrom(typeof(T)))
                {
                    throw new Exception("This handle supports objects of type " + typeof(ObjectType).FullName + " but requested type is not assignable: " + typeof(T).FullName);
                }

                if (factory != null) obj = factory();
                else obj = (T)Activator.CreateInstance(typeof(T));

                if (ObjectEMT != null)
                {
                    ObjectEMT.Set<T>(obj);
                }
                else
                {
                    var castedObj = obj as ObjectType;
#if SanityChecks
                    if (castedObj == null)
                    {
                        throw new UnreachableCodeException("castedObj == null");
                    }
#endif
                    this.Object = castedObj;
                }
            }
            return obj;
        }

        public void SetType<T>(T obj) where T : class
        {
            // Pass-thru to a Multitype object

            if (typeof(T) == typeof(ObjectType))
            {
                this.Object = obj as ObjectType;
                return;
            }

            if (typeof(ObjectType).IsAssignableFrom(typeof(T)))
            {
                ObjectType ot = obj as ObjectType;
                this.Object = ot;
                return;
            }

            var mtObj = _object as IMultiTyped;

            if (mtObj != null)
            {
                mtObj.SetType(obj, typeof(T));
                return;
            }

            throw new ArgumentException("Type not supported by this handle: " + typeof(T).FullName);
        }

        // REVIEW: Non array version with optional array version (for network)?
        public T[] OfType<T>() where T : class
        {
            if (!TryEnsureRetrieved()) return null;

            IEnumerable<T> result = _object as IEnumerable<T>;
            if (result != null) return result.ToArray();

            T resultItem = _object as T;
            if (result != null) return new T[] { resultItem };

            IReadonlyMultiTyped mtObj = _object as IReadonlyMultiTyped;
            if (mtObj != null)
            {
                result = mtObj.OfType<T>();
            }

            if (result == null)
            {
                return null;
            }
            else
            {
                return result.ToArray();
            }
        }
#endif
        [AotReplacement] // TODO - this Func<object> won't be found by current version of Rewriter... need to search for generic args with Func<T> and replace with Func<object>!
        public object AsTypeOrCreate(bool allowMerge, Func<object> factory, Type type) { throw new NotImplementedException("HandleBase2.AsTypeOrCreate"); }
        [AotReplacement]
        public void SetType(object obj, Type type) { throw new NotImplementedException("HandleBase2.SetType"); }
        [AotReplacement]
        public object[] OfType(Type T)
        {
            if (!TryEnsureRetrieved()) return null;

            IEnumerable result = _object as IEnumerable;
            IEnumerable<object> objArray = result.Cast<object>();
            if (result != null) return objArray.ToArray();

            if (_object != null && T.IsAssignableFrom(_object.GetType()))
            {
                return new object[] { _object };
            }

            object resultObj = null;

            IReadonlyMultiTyped mtObj = _object as IReadonlyMultiTyped;
            if (mtObj != null)
            {
                resultObj = mtObj.OfType(T);
            }

            if (resultObj == null)
            {
                return null;
            }
            else
            {
                return new object[] { resultObj };
            }
        }

        public object[] SubTypes
        {
            get
            {
                if (!TryEnsureRetrieved()) return null;

                //if (_object == null) return new object[] { };

                IReadonlyMultiTyped mtObj = _object as IReadonlyMultiTyped;
                if (mtObj != null)
                {
                    return mtObj.SubTypes;
                }

                return new object[] { _object };
            }
        }

        #endregion

        #region Child Accessors

        IHandle ITreeHandle.this[string subpath]
        {
            get
            {
                if (Reference == null) throw new ArgumentNullException("Reference == null");
                if (string.IsNullOrWhiteSpace(subpath)) return this;
                //return this.Reference.GetChild(VosPath.Combine(this.Reference.Path, subpath)).ToHandle(); BUG
                return this.Reference.GetChild(subpath).GetHandle<Folder>();
            }
        }

        IHandle ITreeHandle.this[IEnumerable<string> subpathChunks]
        {
            get
            {
                if (Reference == null) throw new ArgumentNullException("Reference == null");
                if (!subpathChunks.Any()) return this;
                return ((IHandle)this)[subpathChunks.ToSubPath()]; // OPTIMIZE
            }
        }

        IHandle ITreeHandle.this[IEnumerator<string> subpathChunks]
        {
            get
            {
                if (Reference == null) throw new ArgumentNullException("Reference == null");
                return ((IHandle)this)[subpathChunks.ToSubPath()]; // OPTIMIZE
            }
        }

        IHandle ITreeHandle.this[int index, string[] subpathChunks]
        {
            get
            {
                if (Reference == null) throw new ArgumentNullException("Reference == null");
                if (subpathChunks == null) return this;
                if (index == subpathChunks.Length) return this;
                return ((IHandle)this)[subpathChunks.ToSubPath()];
            }
        }

        IHandle ITreeHandle.this[params string[] subpathChunks]
        {
            get
            {
                return ((IHandle)this)[0, subpathChunks];
            }
        }

        public virtual IHandle<T1> GetHandle<T1>(params string[] subpathChunks)
            where T1 : class
        {
            return GetHandle<T1>((IEnumerable<string>)subpathChunks);
        }
        public virtual IHandle<T1> GetHandle<T1>(IEnumerable<string> subpathChunks)
            where T1 : class
        {
            //var parent = subpathChunks.Take(subpathChunks.Length - 1);

            // Uses handle factory, creates a Handle<>.
            return this.Reference.GetChildSubpath(subpathChunks).GetHandle<T1>();
        }

        #endregion

        #region CommandMap

#if TOPORT
        public CommandMap Commands {
            get {
                if (commands == null)
                {
                    commands = new CommandMap();
                    commands.AddCommand("Delete", obj => Delete());
                    commands.AddCommand("Save", obj => Save());
                    //commands.AddCommand("SaveAs", obj => Save());
                    //commands.AddCommand("Rename", obj => Rename());
                    OnInitializingCommands(commands);
                }
                return commands;
            }
        }
        private CommandMap commands;

        protected virtual void OnInitializingCommands(CommandMap commands)
        {
        }
#endif

        #endregion

        #region Misc

        private static ILogger l = Log.Get();
        private static ILogger lLoad = Log.Get("LionFire.OBus.Load");
        private static ILogger lFailLoad = Log.Get("LionFire.OBus.Fail.Load");

        #endregion

    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@color/actionbutton" android:state_selected="true"/>
    <item android:drawable="@color/actionbutton" android:state_pressed="true"/>
    <item android:drawable="@color/actionbar"/>

</selector>


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Encoder</title>
<meta name="date" content="2012-10-22">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

com.google.zxing.qrcode.encoder

Class Encoder

java.lang.Object

com.google.zxing.qrcode.encoder.Encoder

public final class Encoder
extends java.lang.Object

Author:

satorux@google.com (Satoru Takabayashi) - creator, dswitkin@google.com (Daniel Switkin) - ported from C++

Method Summary

Methods

Modifier and Type
Method and Description

static Mode
chooseMode(java.lang.String content)

static QRCode
encode(java.lang.String content,
      ErrorCorrectionLevel ecLevel)

Encode "bytes" with the error correction level "ecLevel".

static QRCode
encode(java.lang.String content,
      ErrorCorrectionLevel ecLevel,
      java.util.Map<EncodeHintType,?> hints)

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

encode

public static QRCode encode(java.lang.String content,
            ErrorCorrectionLevel ecLevel)
                     throws WriterException

Encode "bytes" with the error correction level "ecLevel". The encoding mode will be chosen
 internally by chooseMode(). On success, store the result in "qrCode".

 We recommend you to use QRCode.EC_LEVEL_L (the lowest level) for
 "getECLevel" since our primary use is to show QR code on desktop screens. We don't need very
 strong error correction for this purpose.

 Note that there is no way to encode bytes in MODE_KANJI. We might want to add EncodeWithMode()
 with which clients can specify the encoding mode. For now, we don't need the functionality.

Throws:

WriterException

encode

public static QRCode encode(java.lang.String content,
            ErrorCorrectionLevel ecLevel,
            java.util.Map<EncodeHintType,?> hints)
                     throws WriterException

Throws:

WriterException

chooseMode

public static Mode chooseMode(java.lang.String content)

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method


text:
            {{ site.title }} {{ site.time | date: '%Y' }} |
            Todos direitos reservados. Licenciado através da GPL v2. |
            Powered by Jekyll Doc Theme


text:
package br.com.amaterasu.model.domain;

/**
 * Este package deverá incluir as classes de modelo.
 * Estas classes representam as entidades do banco de dados.
 */


text:
SYNONYM

#### According to
Index Fungorum

#### Published in
null

#### Original name
Nematoloma munnarense Sathe & J.T. Daniel

### Remarks
null


text:
namespace piex {
namespace binary_parse {

CachedPagedByteArray::CachedPagedByteArray(
    const PagedByteArray* paged_byte_array, size_t cache_size)
    : paged_byte_array_(paged_byte_array), cache_size_(cache_size) {}

void CachedPagedByteArray::getPage(size_t page_index,
                                   const unsigned char** begin,
                                   const unsigned char** end,
                                   PagedByteArray::PagePtr* page) const {
  std::lock_guard<std::mutex> lock(mutex_);
  size_t cache_index;
  if (getFromCache(page_index, &cache_index)) {
    // Cache hit, retrieve the page from the cache.
    *begin = cached_pages_[cache_index].begin;
    *end = cached_pages_[cache_index].end;
    *page = cached_pages_[cache_index].page;

    // Remove the page to insert it at the end of the cache later.
    cached_pages_.erase(cached_pages_.begin() +
                        static_cast<std::ptrdiff_t>(cache_index));
  } else {
    // Cache miss, ask PagedByteArray to load the page.
    paged_byte_array_->getPage(page_index, begin, end, page);

    // If the cache is full, remove the first (least recently used) page.
    if (cached_pages_.size() >= cache_size_) {
      cached_pages_.erase(cached_pages_.begin());
    }
  }

  // Cache the most recently used page to the end of the vector.
  CachedPage cache_page;
  cache_page.index = page_index;
  cache_page.page = *page;
  cache_page.begin = *begin;
  cache_page.end = *end;
  cached_pages_.push_back(cache_page);
}

bool CachedPagedByteArray::getFromCache(size_t page_index,
                                        size_t* cache_index) const {
  for (size_t i = 0; i < cached_pages_.size(); ++i) {
    if (cached_pages_[i].index == page_index) {
      *cache_index = i;
      return true;
    }
  }
  return false;
}

}  // namespace binary_parse
}  // namespace piex


text:
Building
========

Requirements
------------
SWIG (http://www.swig.org/)
A compiler (the Visual Studio 2010 C++ Express version should be fine)

To Build
--------
Run the script build_x64.bat - adjust the paths if necessary to the include folders for your java installation

If on 32-bit windows, run the build_win32.bat file

Each script will put the DLL in the corresponding folder (win32 for 32-bit, x64 for 64-bit)

Running
=======
At the console, run::

    javac *.java
    java runme

which should output::

    702.820647167934

Hiccups
=======
If the bin folder of the installation for java is not on the path, you may need to add it.


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--

 -->

<resources xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="app_label" msgid="4489004083283879149">"Bara de stare"</string>
    <string name="status_bar_clear_all_button" msgid="7774721344716731603">"Ştergeţi"</string>
    <string name="status_bar_no_notifications_title" msgid="4755261167193833213">"Nicio notificare"</string>
    <string name="status_bar_ongoing_events_title" msgid="1682504513316879202">"În desfăşurare"</string>
    <string name="status_bar_latest_events_title" msgid="6594767438577593172">"Notificări"</string>
    <string name="battery_low_title" msgid="7923774589611311406">"Conectaţi încărcătorul"</string>
    <string name="battery_low_subtitle" msgid="7388781709819722764">"Bateria se termină:"</string>
    <string name="battery_low_percent_format" msgid="696154104579022959">"A rămas <xliff:g id="NUMBER">%d%%</xliff:g> sau mai puţin."</string>
    <string name="battery_low_why" msgid="7279169609518386372">"Utilizarea bateriei"</string>
    <!-- no translation found for usb_accessory_permission_prompt (3969745913539898765) -->
    <skip />
    <!-- no translation found for usb_device_confirm_prompt (2727793581411868504) -->
    <skip />
    <!-- no translation found for usb_accessory_confirm_prompt (3947430407252730383) -->
    <skip />
    <string name="usb_accessory_uri_prompt" msgid="6332150684964235705">"Aplic. instal. nu funcţ. cu acest acces. USB. Aflaţi despre acest acces. la <xliff:g id="URL">%1$s</xliff:g>"</string>
    <string name="title_usb_accessory" msgid="4966265263465181372">"Accesoriu USB"</string>
    <string name="label_view" msgid="6304565553218192990">"Afişaţi"</string>
    <string name="always_use_accessory" msgid="1210954576979621596">"Utiliz. în mod prestabilit pt. acest accesoriu USB"</string>
</resources>


text:
package fixtures;

import java.util.HashMap;

public class Constants {
        public static final int INFO_NOT_LOGGED_IN = 1001;
        public static final int INFO_NOT_ADMIN = 1002;
        public static final int INFO_PLAYER_NOT_FOUND = 1003;
        public static final int INFO_PSW_ERR = 1004;
        public static final int INFO_VISITOR = 1005;
        public static final int INFO_DUPLICATED = 1006;

        public static final int INFO_ACTIVITY_HAS_BEGUN = 3007;
        public static final int INFO_ACTIVITY_APPLIED_LIMIT = 3008;
        public static final int INFO_ACTIVITY_SELECTED_LIMIT = 3009;
        public static final int INFO_ACTIVITY_CREATION_LIMIT = 3010;

        public static final int INFO_CAPTCHA_NOT_MATCHED = 4001;

        public static final int INFO_FOREIGN_PARTY_REGISTRATION_REQUIRED = 5001;
        public static final int INFO_TEMP_FOREIGN_PARTY_RECORD_NOT_FOUND = 5002;

        // language names
        public static final String EN_GB = "en_gb";
        public static final String EN_US = "en_us";
        public static final String ZH_HK = "zh_hk";
        public static final String ZH_CN = "zh_cn";

        // field names
        public static final String ADMIN_EMAIL = "admin@qiutongqu.com";
        public static final String HONGKONGRESORT_TEAM = "hongkongresort_team";
        public static final String WELCOME = "welcome";
        public static final String VERIFY_INSTRUCTION = "verify_instruction";
        public static final String RESET_PASSWORD_TITLE = "reset_password_title";
        public static final String RESET_PASSWORD_INSTRUCTION = "reset_password_instruction";

        // language map
        public static final HashMap<String, String> ZH_HK_MAP = new HashMap<>();

        static {
                ZH_HK_MAP.put(HONGKONGRESORT_TEAM, "求同去團隊");
                ZH_HK_MAP.put(WELCOME, "感謝註冊本站會員");
                ZH_HK_MAP.put(VERIFY_INSTRUCTION, "你好 %s, 請點擊以下鏈接以完成郵箱驗證: %s");
                ZH_HK_MAP.put(RESET_PASSWORD_TITLE, "密碼重置指引");
                ZH_HK_MAP.put(RESET_PASSWORD_INSTRUCTION, "你好 %s, 請點擊以下鏈接以完成密碼重置: %s");
        }

        public static final HashMap<String, HashMap<String, String>> LANG_MAP = new HashMap<>();

        static {
                LANG_MAP.put(ZH_HK, ZH_HK_MAP);
        }
}


text:
                Copyright © 2015 WSDC All rights reserved.
                 Designed and Developed by WSDC


text:
<!DOCTYPE html>

  <title>Elan Kvitko</title>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="../css/style.css">
  <link rel="stylesheet" href="../css/blog.css">
  <link rel="stylesheet" href="../materialize/css/materialize.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

//elan kvitko

<< Go Back Home

<< Go Back

Arrays - Hashes - Faceoff!

March 6th, 2016

              names = Array.new
              names = []
              names = ["Elan"]
              # All of these will create an array

            See that up there? Those are just a few ways of making an array. It is really simple. Naming your array is the same as making a variable equal to your array. Now what is an array? An array is a collection of objects whether they be:

 strings: "Elan",
fixed numbers/integers: 1, 2, 3,
 float numbers/decimals: 1.0, 2.5, 3.2,
 arrays: ["elan", "kvitko"], and more.

              person = Hash.new
              person = {}

              person = {
              :name => "elan",
              :city => "nyc",
              :favorite_food => "pizza"
              :favorite_number => 15
              }

              # All of these will create a Hash

            Those things up there. They're what we call hashes in Ruby. A hash is another way of storing data except a hash works kind of like a dictionary. You see how I create a hash called person and if I wanted to represent myself as an object along with all of my attributes, I would use a hash. When I say a hash works like a dictionary, all it means is that there is a key which is the same as a word in a dictionary, and then you see the little hash rocket (what we call the equal sign with the greater than symbol. it's a cool word and pure genius!), which assigns whatever you put on the right of it the value which acts like a definition.

Check Out Some Other Posts!

web// Git & Version Control

Lorem ipsum dolor sit amet.

web// CSS Concepts

Lorem ipsum dolor sit amet.

web// Arrays & Hashes

Lorem ipsum dolor sit amet.

web// Enumerable Methods

Lorem ipsum dolor sit amet.

web// Ruby Classes

Lorem ipsum dolor sit amet.

web// JavaScript - Ruby

Lorem ipsum dolor sit amet.

Follow Me

Copyright, 2016 ©

//elan kvitko


text:
package com.dylanvann.fastimage;

import static com.dylanvann.fastimage.FastImageRequestListener.REACT_ON_ERROR_EVENT;
import static com.dylanvann.fastimage.FastImageRequestListener.REACT_ON_LOAD_END_EVENT;
import static com.dylanvann.fastimage.FastImageRequestListener.REACT_ON_LOAD_EVENT;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.graphics.PorterDuff;
import android.os.Build;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;

import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;

import javax.annotation.Nullable;

class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> implements FastImageProgressListener {

    static final String REACT_CLASS = "FastImageView";
    static final String REACT_ON_LOAD_START_EVENT = "onFastImageLoadStart";
    static final String REACT_ON_PROGRESS_EVENT = "onFastImageProgress";
    private static final Map<String, List<FastImageViewWithUrl>> VIEWS_FOR_URLS = new WeakHashMap<>();

    @Nullable
    private RequestManager requestManager = null;

    @NonNull
    @Override
    public String getName() {
        return REACT_CLASS;
    }

    @NonNull
    @Override
    protected FastImageViewWithUrl createViewInstance(@NonNull ThemedReactContext reactContext) {
        if (isValidContextForGlide(reactContext)) {
            requestManager = Glide.with(reactContext);
        }

        return new FastImageViewWithUrl(reactContext);
    }

    @ReactProp(name = "source")
    public void setSource(FastImageViewWithUrl view, @Nullable ReadableMap source) {
        view.setSource(source);
    }

    @ReactProp(name = "defaultSource")
    public void setDefaultSource(FastImageViewWithUrl view, @Nullable String source) {
        view.setDefaultSource(
                ResourceDrawableIdHelper.getInstance()
                        .getResourceDrawable(view.getContext(), source));
    }

    @ReactProp(name = "tintColor", customType = "Color")
    public void setTintColor(FastImageViewWithUrl view, @Nullable Integer color) {
        if (color == null) {
            view.clearColorFilter();
        } else {
            view.setColorFilter(color, PorterDuff.Mode.SRC_IN);
        }
    }

    @ReactProp(name = "resizeMode")
    public void setResizeMode(FastImageViewWithUrl view, String resizeMode) {
        final FastImageViewWithUrl.ScaleType scaleType = FastImageViewConverter.getScaleType(resizeMode);
        view.setScaleType(scaleType);
    }

    @Override
    public void onDropViewInstance(@NonNull FastImageViewWithUrl view) {
        // This will cancel existing requests.
        view.clearView(requestManager);

        if (view.glideUrl != null) {
            final String key = view.glideUrl.toString();
            FastImageOkHttpProgressGlideModule.forget(key);
            List<FastImageViewWithUrl> viewsForKey = VIEWS_FOR_URLS.get(key);
            if (viewsForKey != null) {
                viewsForKey.remove(view);
                if (viewsForKey.size() == 0) VIEWS_FOR_URLS.remove(key);
            }
        }

        super.onDropViewInstance(view);
    }

    @Override
    public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
        return MapBuilder.<String, Object>builder()
                .put(REACT_ON_LOAD_START_EVENT, MapBuilder.of("registrationName", REACT_ON_LOAD_START_EVENT))
                .put(REACT_ON_PROGRESS_EVENT, MapBuilder.of("registrationName", REACT_ON_PROGRESS_EVENT))
                .put(REACT_ON_LOAD_EVENT, MapBuilder.of("registrationName", REACT_ON_LOAD_EVENT))
                .put(REACT_ON_ERROR_EVENT, MapBuilder.of("registrationName", REACT_ON_ERROR_EVENT))
                .put(REACT_ON_LOAD_END_EVENT, MapBuilder.of("registrationName", REACT_ON_LOAD_END_EVENT))
                .build();
    }

    @Override
    public void onProgress(String key, long bytesRead, long expectedLength) {
        List<FastImageViewWithUrl> viewsForKey = VIEWS_FOR_URLS.get(key);
        if (viewsForKey != null) {
            for (FastImageViewWithUrl view : viewsForKey) {
                WritableMap event = new WritableNativeMap();
                event.putInt("loaded", (int) bytesRead);
                event.putInt("total", (int) expectedLength);
                ThemedReactContext context = (ThemedReactContext) view.getContext();
                RCTEventEmitter eventEmitter = context.getJSModule(RCTEventEmitter.class);
                int viewId = view.getId();
                eventEmitter.receiveEvent(viewId, REACT_ON_PROGRESS_EVENT, event);
            }
        }
    }

    @Override
    public float getGranularityPercentage() {
        return 0.5f;
    }

    private static boolean isValidContextForGlide(final Context context) {
        Activity activity = getActivityFromContext(context);

        if (activity == null) {
            return false;
        }

        return !isActivityDestroyed(activity);
    }

    private static Activity getActivityFromContext(final Context context) {
        if (context instanceof Activity) {
            return (Activity) context;
        }

        if (context instanceof ThemedReactContext) {
            final Context baseContext = ((ThemedReactContext) context).getBaseContext();
            if (baseContext instanceof Activity) {
                return (Activity) baseContext;
            }

            if (baseContext instanceof ContextWrapper) {
                final ContextWrapper contextWrapper = (ContextWrapper) baseContext;
                final Context wrapperBaseContext = contextWrapper.getBaseContext();
                if (wrapperBaseContext instanceof Activity) {
                    return (Activity) wrapperBaseContext;
                }
            }
        }

        return null;
    }

    private static boolean isActivityDestroyed(Activity activity) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            return activity.isDestroyed() || activity.isFinishing();
        } else {
            return activity.isFinishing() || activity.isChangingConfigurations();
        }

    }

    @Override
    protected void onAfterUpdateTransaction(@NonNull FastImageViewWithUrl view) {
        super.onAfterUpdateTransaction(view);
        view.onAfterUpdate(this, requestManager, VIEWS_FOR_URLS);
    }
}


text:
package org.wiztools.restclient;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Subhash
 */
final public class GlobalOptions implements IGlobalOptions {

    private static Logger LOG = Logger.getLogger(GlobalOptions.class.getName());

    public static final Integer DEFAULT_TIMEOUT_MILLIS = new Integer(60000);
    private static final File CONF_DIR = new File(
            System.getProperty("user.home") +
            System.getProperty("file.separator") +
            ".rest-client");
    private static final File CONF_PROPERTY = new File(CONF_DIR, "rest-client.properties");

    private final Properties prop = new Properties();

    private static GlobalOptions me;
    Lock lock = new ReentrantLock();

    private int requestTimeoutInMillis;

    public int getRequestTimeoutInMillis() {
        return requestTimeoutInMillis;
    }

    public void setRequestTimeoutInMillis(int requestTimeoutInMillis) {
        this.requestTimeoutInMillis = requestTimeoutInMillis;
    }

    public GlobalOptions(){
        // Load default properties:
        prop.setProperty("request-timeout-in-millis", "60000");

        if(!CONF_DIR.exists()){
            LOG.info("Configuration directory does not exist. Creating...");
            CONF_DIR.mkdir();
        }
        if(CONF_PROPERTY.exists()){
            try{
                prop.load(new FileInputStream(CONF_PROPERTY));
            }
            catch(IOException ex){
                LOG.log(Level.WARNING, "Failed loading default properties!", ex);
            }
        }
    }

    public void setProperty(String key, String value){
        if(value == null){
            value = "";
        }
        prop.setProperty(key, value);
    }

    public void removeProperty(String key){
        prop.remove(key);
    }

    public String getProperty(String key){
        return prop.getProperty(key);
    }

    public void writeProperties(){
        try{
            prop.store(new FileOutputStream(CONF_PROPERTY), "RESTClient Properties");
        }
        catch(IOException ex){
            LOG.log(Level.WARNING, "Error writing to properties!", ex);
        }
    }

    public void acquire(){
        lock.lock();
    }

    public void release(){
        lock.unlock();
    }

}